# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22253 | King_God_OnionPringles (#40) | Fully Generate (KRIII5_FG) | C++98 | 500 ms | 392644 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<bits/stdc++.h>
#define je 1000000007
using namespace std;
long long gop(int x, int y){
long long poww = x;
long long ans = 1;
int left = y;
while(left){
if(left & 1){
ans = (ans * poww) % je;
}
poww = (poww * poww) % je;
left >>= 1;
}
return ans;
}
int cnt[100000001];
int main(){
long long n;
scanf("%lld",&n);
long long ans = 1;
int pnt = 1, now = 2;
for(int i=1;;i++){
if(i<=2){
cnt[i] = i;
}else{
if(pnt == 0){
now++;
pnt = cnt[now];
}
cnt[i] = now;
pnt--;
}
if(n <= cnt[i]){
ans = (ans * gop(i,n)) % je;
break;
}else{
n -= cnt[i];
ans = (ans * gop(i,cnt[i])) % je;
}
}
printf("%lld",ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |