| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 22653 | AJAE (#40) | Fully Generate (KRIII5_FG) | C++14 | 239 ms | 246020 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
using namespace std;
using ll = long long;
const ll MMOD = 1000000007;
const ll MAXN = 31347599;
inline 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[MAXN] = {0,1,2,2,};
int sss[6] = {0,1,2,4,12,36};
int main()
{
ll n;
ll cnt = 5;
ll ans = 36;
scanf("%lld", &n);
if(n<=5) {
printf("%d\n", sss[n]);
return 0;
}
ll gsize = 4;
bool sw = true;
for(int i=3;sw;++i){
ll ttmp = 1;
ll st = gsize;
for(ll j=0;j<arr[i];++j) {
cnt += i;
if (cnt >= n) {
ans = (ans * popo(ttmp, i))%MMOD;
ans = (ans * popo(gsize, i - (cnt-n)))%MMOD;
printf("%lld\n", ans);
return 0;
}
arr[gsize] = i;
ttmp = (ttmp * gsize) % MMOD;
gsize++;
}
ans = (ans * popo(ttmp, i))%MMOD;
}
return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
