結果

問題 No.500 階乗電卓
ユーザー ohreitetsuohreitetsu
提出日時 2018-05-28 22:48:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 551 bytes
コンパイル時間 430 ms
コンパイル使用メモリ 64,340 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-12 20:16:07
合計ジャッジ時間 1,447 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
			}
			sscanf(p1,"%lld",&v);
		}
	}
	cout<<v<<endl;
	return 0;
}
0