제출 #1279115

#제출 시각아이디문제언어결과실행 시간메모리
1279115dostsAsceticism (JOI18_asceticism)C++20
49 / 100
1095 ms1856 KiB
#include <bits/stdc++.h> #pragma GCC optimize("O3,Ofast,unroll-loops") #pragma GCC target("avx2") #define int long long #define pii pair<int,int> #define vi vector<int> #define ff first #define ss second #define sp << " " << #define all(x) x.begin(),x.end() #define big(x) ((int)(x.size())) using namespace std; const int MOD = 1e9+7, LIM = 1e6+1, inf = 2e9; const int N = 1e5+1; int add(int x,int y) { if ((x + y) >= MOD) return x + y - MOD; return x + y; } int mult(int x,int y) { return (x * y) % MOD; } int expo(int x,int y) { if (!y) return 1; int e = expo(x, y >> 1); e = mult(e, e); if (y & 1) e = mult(e, x); return e; } void solve() { int n,k; cin >> n >> k; k--; k = min(k,n-k-1); vi dp(n+1,0),dp2(n+1,0); dp[0] = dp2[0] = 1; for (int i = 1;i<=n;i++) { for (int j = 1;j<i && j <= k;j++) { dp[j] = add(mult(dp2[j],j+1),mult(dp2[j-1],i-j)); } dp.swap(dp2); } cout << dp2[k] << '\n'; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); #ifdef Dodi freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif int t = 1; //cin >> t; while (t --> 0) solve(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...