Submission #21420

#TimeUsernameProblemLanguageResultExecution timeMemory
21420gs14004순열 (kriii4_T)C++11
100 / 100
203 ms2020 KiB
#include <bits/stdc++.h> using namespace std; typedef long long lint; typedef long double llf; typedef pair<int, int> pi; const int mod = 1e9 + 7; lint ipow(lint x, lint p){ lint ret = 1, piv = x % mod; while(p){ if(p&1) ret *= piv; piv *= piv; ret %= mod; piv %= mod; p >>= 1; } return ret % mod; } int n, k; int main(){ cin >> n >> k; lint ans = 0; for(int i=k+1; i<=n; i++){ ans += (n - i + 1) * ipow(i+1, mod - 2) % mod; ans %= mod; } for(int i=2; i<=n+1; i++) ans = (ans * i) % mod; cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...