# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22317 | 크리콘 B번 문제는 그리디로 풀려요 (#40) | Fully Generate (KRIII5_FG) | C++98 | 263 ms | 130468 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, gop[52000];
int main(){
poi[1]=1, gop[1]=1;
poi[2]=poi[3]=2, gop[2]=6; cnt=4; sum=5;
for(int i=3;; i++){
gop[i]=1;
for(int j=poi[i]; j--;){
poi[cnt]=i;
gop[i] = gop[i]*cnt % mod;
cnt++, sum+=i;
}
if(sum > mx) break;
}
scanf("%lld", &N); lld dap=1;
lld N2=N, lim=0, comp=0;
for(int i=1; i<cnt; i++){
if(N2 >= poi[i])lim++, N2 -= poi[i];
else { dap = exp(i,N2)%mod; break; }
}
for(int i=1; i<cnt; i++){
if(comp + poi[i] <= lim) dap = dap*exp(gop[i],i)%mod, comp += poi[i];
else break;
}
for(lld i=comp+1; i<=lim; i++) dap = dap*exp(i,poi[i])%mod;
printf("%lld", dap);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |