1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | #include <stdio.h> #define ten 10 int arr[1000000] = { 0 }; int cnt = 1; int main() { int n,up=0; scanf("%d", &n); arr[1] = 1; for (int i = 2; i <= n; i++) { for (int j = 1; j <= cnt; j++) { arr[j] = (arr[j] * i + up); up = (arr[j] / ten); arr[j] %= ten; } while (up != 0) { arr[++cnt] = up % ten; up /= ten; } } for (int i = cnt; i >= 1; i--) { printf("%d", arr[i]); } } | cs |
'알고리즘 > 큰 수의 계산' 카테고리의 다른 글
팩토리얼 숫자 빈도수 더블릿 (0) | 2019.02.28 |
---|---|
2*1, 2*2 타일링 더블릿 (0) | 2019.02.18 |