Submission #70031

#TimeUsernameProblemLanguageResultExecution timeMemory
70031yogahmadAsceticism (JOI18_asceticism)C++14
100 / 100
29 ms2328 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; #define fbo find_by_order #define ook order_of_key #define f first #define s second #define pb push_back #define reset(a,b) memset(a,b,sizeof a); #define MOD 1000000007 #define MID (l+r)/2 #define ALL(x) x.begin(),x.end() #define debug(x) cout<<#x<<" = "<<(x)<<endl #define mx 100003 #define pc(x) putchar_unlocked(x); typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> pbds; long long fak[mx],inv[mx],n,k; long long C(int n,int k){ long long ret=fak[n]*inv[k]%MOD; ret=ret*inv[n-k]%MOD; return ret; } long long pow_(long long a,int b){ if(b==0)return 1; long long sem=pow_(a,b/2); sem=(sem*sem)%MOD; if(b&1)sem=(sem*a)%MOD; return sem; } int main(){ fak[1]=inv[1]=inv[0]=inv[1]=1; for(int i=2;i<=1e5+5;i++){ fak[i]=fak[i-1]*i%MOD; inv[i]=(MOD-1LL*(MOD/i)*inv[MOD%i]%MOD)%MOD; } for(int i=1;i<=1e5+5;i++){ inv[i]=inv[i]*inv[i-1]%MOD; } long long m; cin>>n>>m; long long jaw=0; m--; for(int k=0;k<=m;k++){ long long sem; sem=C(n+1,k)*pow_(m+1-k,n)%MOD; if(k&1){ sem=(MOD-sem)%MOD; } jaw=(jaw+sem)%MOD; } cout<<jaw<<endl; }

Compilation message (stderr)

asceticism.cpp: In function 'int main()':
asceticism.cpp:37:15: warning: operation on 'inv[1]' may be undefined [-Wsequence-point]
  fak[1]=inv[1]=inv[0]=inv[1]=1;
         ~~~~~~^~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...