Submission #22466

#TimeUsernameProblemLanguageResultExecution timeMemory
22466AJAE (#40)Fully Generate (KRIII5_FG)C++11
2 / 7
500 ms247080 KiB
#include <iostream> #include <vector> using namespace std; using ll = long long; ll MMOD = 1000000007; ll popo(ll a, ll p) { ll r =1 ; while(p) { if(p&1) r= (r*a)%MMOD; a = (a*a) % MMOD; p >>= 1LL; } return r; } ll arr[31347599]; int main() { ios_base::sync_with_stdio(false); ll n; ll cnt = 0; ll ans = 1; cin >> n; if (n <= 2){ cout << n << '\n'; return 0; } else if(n==3) { cout << "4\n"; return 0; } else if(n==4) { cout << "12\n"; return 0; } else if(n==5) { cout << "36\n"; return 0; } int gsize = 4; arr[0] = 0; arr[1] = 1; arr[2] = 2; arr[3] = 2; cnt = 1+2+2; ans = 2*2*3*3; bool sw = true; for(int i=3;sw;++i){ ll &tmp = arr[i]; ll ttmp = 1; int st = gsize; for(ll j=0;j<tmp;++j) { arr[gsize] = i; gsize++; cnt += i; if (cnt >= n) { ans = (ans * popo(ttmp, i))%MMOD; arr[gsize-1] = i - (cnt-n); ans = (ans * popo(gsize-1, arr[gsize-1]))%MMOD; sw = false; break; } ttmp = (ttmp*(gsize-1))%MMOD; } if(sw) { ans = (ans * popo(ttmp, i))%MMOD; } } cout << ans << '\n'; return 0; }

Compilation message (stderr)

FG.cpp: In function 'int main()':
FG.cpp:49:13: warning: unused variable 'st' [-Wunused-variable]
         int st = gsize;
             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...