# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1163335 | kjy2014 | 팩토리얼 세제곱들의 합 (YDX14_fact) | C++20 | 0 ms | 328 KiB |
#include<bits/stdc++.h>
#define M 40
#define B 1000000000000
int power(int a,int k)
{
return k==0?1:power(a,k-1)*a;
}
int main()
{
static long long aa[M],ss[M];
int n,k,h,i,x;
scanf("%d%d",&n,&k);
aa[0]=ss[0]=1;
for(i=1;i<=n;i++)
{
x=power(i,k);
for(h=0;h<M;h++)
aa[h]*=x;
for(h=0;h+1<M;h++)
aa[h+1]+=aa[h]/B,aa[h]%=B;
if(aa[M-1]>=B)
{
printf("bad\n");
return 0;
}
for(h=0;h<M;h++)
ss[h]+=aa[h];
for(h=0;h+1<M;h++)
ss[h+1]+=ss[h]/B,ss[h]%=B;
if(ss[M-1]>=B)
{
printf("bad\n");
return 0;
}
}
h=0;
while(ss[h]==0)
h++;
while(ss[h]%10==0)
ss[h]/=10;
printf("%lld\n",ss[h]%10);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |