Submission #22926

#TimeUsernameProblemLanguageResultExecution timeMemory
22926solarmagicFully Generate (KRIII5_FG)C++14
7 / 7
303 ms251116 KiB
#include<stdio.h> #define M ((ll)1e9 + 7) typedef long long ll; ll n,a[32000000]; ll f(ll a, ll b) { if(!b) return 1; if(b & 1) return f(a,b-1) * a % M; ll k = f(a, b>>1); return k*k%M; } int main() { scanf("%lld",&n); if(n <= 11) { ll r[12] = {0,1,2,4,12,36,144,576,2304,11520,57600,288000}; printf("%lld", r[n]); } else { a[1] = 1, a[2] = 2, a[3] = 2, a[4] = 3, a[5] = 3; ll res = 1, i=4, s=5; ll tmp = 6; for(ll j=6;s+a[i]<n;i++) { for(ll k=0;j<32000000 && k<a[i];k++) a[j++] = i; s += a[i]; if(a[i] == a[i-1]) tmp = (tmp * i) % M; else res = (res * f(tmp, a[i-1])) % M, tmp = i; } res = (res * f(tmp, a[i-1])) % M; res = (res * f(i, n-s)) % M; printf("%lld", res); } return 0; }

Compilation message (stderr)

FG.cpp: In function 'int main()':
FG.cpp:12:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld",&n);
                     ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...