結果

問題 No.500 階乗電卓
ユーザー Naoyk1212
提出日時 2017-04-07 23:36:55
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 638 bytes
コンパイル時間 1,214 ms
コンパイル使用メモリ 162,460 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-16 03:16:09
合計ジャッジ時間 1,926 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define int long long

int StringToInt(string str){
	stringstream ss;
	ss << str;
	int num;
	ss >> num;
	return num;
}

int check(int n, int a){
	string str = to_string(n * a);
	if(str.length() > 12){
		str = str.substr(str.length() - 12, 12);
	}
	
	bool flag = false;
	for(int i = 0; i < str.length(); i++){
		if(str[i] != '0'){
			flag = true;
		}
	}
	
	return StringToInt(str);
}

signed main(){
	int n;
	cin >> n;
	int ans = 1;
	if(n >= 50){
		cout << "000000000000" << endl;
	}else{
		bool ok = false;
		for(int i = 1; i <= n; i++){
			ans = check(ans, i);
		}
		cout << ans << endl;
	}
}
0