Submission #77386

#TimeUsernameProblemLanguageResultExecution timeMemory
77386tmwilliamlin168Asceticism (JOI18_asceticism)C++14
100 / 100
38 ms1864 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long const int mxN=1e5, M=1e9+7; int n, k; ll fi[mxN+1], ans; ll exp(ll b, int p) { ll r=1; while(p) { if(p&1) r=b*r%M; b=b*b%M; p/=2; } return r; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n >> k; fi[0]=1; for(int i=1; i<=n; ++i) fi[i]=exp(i, M-2)*fi[i-1]%M; for(int j=0; j<=1; ++j) for(int i=0; i<k-j; ++i) ans+=(i&1^j?M-1:1)*exp(k-j-i, n)%M*fi[i]%M*fi[n-i]%M; for(int i=2; i<=n; ++i) ans=i*ans%M; cout << ans; }

Compilation message (stderr)

asceticism.cpp: In function 'int main()':
asceticism.cpp:31:11: warning: suggest parentheses around arithmetic in operand of '^' [-Wparentheses]
    ans+=(i&1^j?M-1:1)*exp(k-j-i, n)%M*fi[i]%M*fi[n-i]%M;
          ~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...