# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
13632 | baneling100 | 팩토리얼 세제곱들의 합 (YDX14_fact) | C++98 | 0 ms | 1084 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>
int N, K, Fact=1, Zero, Ans1=1, Ans2;
int Table[10][4]={{},{0,1,1,1},{0,2,4,8},{0,3,9,7},{0,4,6,4},{0,5,5,5},{0,6,6,6},{0,7,9,3},{0,8,4,2},{0,9,1,9}};
int main(void) {
int i;
scanf("%d %d",&N,&K);
if(K)
for(i=1 ; i<=N ; i++) {
Fact*=i;
while(!(Fact%10)) Fact/=10, Zero++;
Fact%=10;
if(Ans2>K*Zero) Ans2=K*Zero, Ans1=Table[Fact][K];
else if(Ans2==K*Zero) {
Ans1+=Table[Fact][K];
if(Ans1==10) Ans1=1, Ans2++;
Ans1%=10;
}
}
else {
Ans1=N+1;
while(!(Ans1%10)) Ans1/=10;
Ans1%=10;
}
printf("%d",Ans1);
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |