# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22291 | 크리콘 B번 문제는 그리디로 풀려요 (#40) | Fully Generate (KRIII5_FG) | C++98 | 500 ms | 130060 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<stdio.h>
typedef long long lld;
const lld mx = 1000000000000;
const lld mod = 1000000007;
lld exp(lld a, lld b){
lld g=1, a0=a, b0=b;
while(b){
if(b&1)g=g*a%mod;
b>>=1, a=a*a%mod;
}
return g;
}
int poi[33010101], cnt;
lld sum, N;
int main(){
poi[1]=1;
poi[2]=poi[3]=2; cnt=4; sum=5;
for(int i=3;; i++){
for(int j=poi[i]; j--;) poi[cnt++]=i, sum+=i;
if(sum > mx) break;
}
scanf("%lld", &N); lld dap=1;
for(int i=1; i<cnt; i++){
if(N >= poi[i]) dap = dap*exp(i,poi[i])%mod, N -= poi[i];
else { dap = dap*exp(i,N)%mod; break; }
}
printf("%lld", dap);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |