結果
問題 |
No.500 階乗電卓
|
ユーザー |
![]() |
提出日時 | 2017-04-07 23:21:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 687 bytes |
コンパイル時間 | 1,442 ms |
コンパイル使用メモリ | 162,288 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-16 03:03:50 |
合計ジャッジ時間 | 2,148 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 WA * 2 |
ソースコード
#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; } } if(flag == true){ return StringToInt(str); }else{ return -1; } } 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; } }