Submission #553470

#TimeUsernameProblemLanguageResultExecution timeMemory
553470MohamedAhmed04Asceticism (JOI18_asceticism)C++14
49 / 100
42 ms25016 KiB
#include <bits/stdc++.h> using namespace std ; const int mod = 1e9 + 7 ; int Add(int x , int y) { int z = x + y ; if(z >= mod) z -= mod ; return z ; } int Sub(int x , int y) { int z = x - y ; if(z < 0) z += mod ; return z ; } int Mul(int x , int y) { return (x * 1ll * y) % mod ; } int powlog(int base , int power) { if(power == 0) return 1 ; int x = powlog(base , power / 2) ; x = Mul(x , x) ; if(power & 1) x = Mul(x , base) ; return x ; } int modinv(int x) { return powlog(x , mod-2) ; } int Div(int x , int y) { return Mul(x , modinv(y)) ; } const int MAX = 3000 + 10 ; int arr[MAX] ; int n , k ; int dp[MAX][MAX] ; int main() { ios_base::sync_with_stdio(0) ; cin.tie(0) ; cin>>n>>k ; dp[0][0] = 1 ; for(int i = 1 ; i <= n ; ++i) { for(int j = 1 ; j <= k ; ++j) dp[i][j] = Add(Mul(dp[i-1][j-1] , i-j+1) , Mul(dp[i-1][j] , j)) ; } return cout<<dp[n][k]<<"\n" , 0 ; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...