結果
問題 | No.500 階乗電卓 |
ユーザー |
![]() |
提出日時 | 2017-04-07 22:45:57 |
言語 | C (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 2,000 ms |
コード長 | 398 bytes |
コンパイル時間 | 187 ms |
コンパイル使用メモリ | 29,184 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 02:50:51 |
合計ジャッジ時間 | 995 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include<stdio.h>typedef long long ll;int main(void){ll N, r;int i, is_ovf;while(scanf("%lld", &N)==1){r=1;is_ovf=0;if(N>=58){r=0;is_ovf=1;}else{for(i=1;i<=N;i++){r=(r*i);if(r>=1000000000000){r%=1000000000000;is_ovf=1;}}}if(is_ovf) printf("%012lld\n", r);else printf("%lld\n", r);}return 0;}