Submission #20027

#TimeUsernameProblemLanguageResultExecution timeMemory
20027cki86201순열 (kriii4_T)C++14
100 / 100
260 ms1720 KiB
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <memory.h> #include <math.h> #include <assert.h> #include <stack> #include <queue> #include <map> #include <set> #include <string> #include <algorithm> #include <iostream> #include <functional> #include <unordered_map> #include <unordered_set> using namespace std; typedef long long ll; typedef pair<int, int> Pi; #define Fi first #define Se second #define pb(x) push_back(x) #define sz(x) (int)x.size() #define rep(i,n) for(int i=0;i<n;i++) #define all(x) x.begin(),x.end() const ll MOD = 1e9 + 7; ll pw(ll x, ll y){ ll res = 1; while(y){ if(y & 1)res = res * x % MOD; x = x * x % MOD; y >>= 1; } return res; } int main(){ ll f = 1; int n, k; scanf("%d%d", &n, &k); if(n == k){ printf("0"); return 0; } for(int i=1;i<=n+1;i++)f = i * f % MOD; ll s = 0; for(int i=k+1;i<=n;i++){ s += (n+1-i) * pw(i+1, MOD-2); s %= MOD; } f = f * s % MOD; printf("%lld", f); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...