Submission #10299

#TimeUsernameProblemLanguageResultExecution timeMemory
10299gs14004팩토리얼 세제곱들의 합 (YDX14_fact)C++98
1 / 1
0 ms1088 KiB
#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); }
#Verdict Execution timeMemoryGrader output
Fetching results...