# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
27203 | TAMREF | 팩토리얼 세제곱들의 합 (YDX14_fact) | C++11 | 0 ms | 1116 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 <cstdio>
int fact(int x){
if(x == 0) return 1;
return fact(x-1) * x % 10000;
}
int pow(int x, int t){
int r = 1;
for (int i=0; i<t; i++) {
r *= x;
r %= 10000;
}
return r;
}
int main(){
int n,k;
scanf("%d %d",&n,&k);
int res = 0;
for (int i=0; i<=n; i++) {
res += pow(fact(i),k);
}
while (res%10 == 0) {
res /= 10;
}
printf("%d",res%10);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |