結果
| 問題 | No.500 階乗電卓 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2018-05-28 22:53:03 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 614 bytes |
| コンパイル時間 | 504 ms |
| コンパイル使用メモリ | 65,204 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 07:53:44 |
| 合計ジャッジ時間 | 1,265 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
#include <iostream>
#include <string.h>
using namespace std;
typedef long long LL;
LL MAX=999999999999;
int main(int argc, char* argv[])
{
LL N;
cin>>N;
int i;
LL v=1;
for (i=2;i<=N;i++){
v=v*i;
if (v>MAX){
char p[100];
sprintf(p,"%lld",v);
char *p1=p+strlen(p)-12;
char *p2=p1;
bool allZero=true;
while (*p2!='\0'){
if (*p2!='0'){
allZero=false;
break;
}
p2++;
}
if (allZero==true){
cout<<"000000000000"<<endl;
return 0;
}
if (i<N){
sscanf(p1,"%lld",&v);
}else{
cout<<p1<<endl;
return 0;
}
}
}
cout<<v<<endl;
return 0;
}