Submission #940858

#TimeUsernameProblemLanguageResultExecution timeMemory
940858rainboy팩토리얼 세제곱들의 합 (YDX14_fact)C11
1 / 1
1 ms852 KiB
#include <stdio.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; }

Compilation message (stderr)

fact.c: In function 'main':
fact.c:14:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...