結果
問題 | No.500 階乗電卓 |
ユーザー |
![]() |
提出日時 | 2017-06-28 00:27:14 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 704 bytes |
コンパイル時間 | 827 ms |
コンパイル使用メモリ | 87,732 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 03:02:43 |
合計ジャッジ時間 | 1,450 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
#include <algorithm>#include <cstdio>#include <iostream>#include <map>#include <cmath>#include <queue>#include <set>#include <sstream>#include <stack>#include <string>#include <vector>#include <stdlib.h>#include <stdio.h>#include <bitset>using namespace std;#define FOR(I,A,B) for(int I = (A); I < (B); ++I)typedef long long ll;int main(){ll n;cin >> n;if (n >= 10000) n = 10000;ll ans = 1;int keta = 1;ll truenum = 1;bool over = false;FOR(i,1,n+1){if(keta < 13) truenum *= i;else over = true;keta = log10(truenum) + 1;ans *= i;ans %= 1000000000000;}if(over) printf("%012lld\n", ans);else printf("%lld\n", ans);return 0;}