結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
nenuon
|
| 提出日時 | 2017-06-28 00:27:14 |
| 言語 | C++14 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 704 bytes |
| 記録 | |
| コンパイル時間 | 519 ms |
| コンパイル使用メモリ | 103,484 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-11 07:34:35 |
| 合計ジャッジ時間 | 1,217 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
nenuon