# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
940858 | rainboy | 팩토리얼 세제곱들의 합 (YDX14_fact) | C11 | 1 ms | 852 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |