結果
問題 |
No.500 階乗電卓
|
ユーザー |
![]() |
提出日時 | 2018-03-15 23:02:26 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 1,020 ms |
コンパイル使用メモリ | 72,448 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 03:07:23 |
合計ジャッジ時間 | 1,487 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 |
ソースコード
// No.500 階乗電卓 // https://yukicoder.me/problems/no/500 // #include <iostream> #include <string> #include <iomanip> #include <sstream> using namespace std; string solve(long long int N); int main() { std::cin.tie(nullptr); std::ios::sync_with_stdio(false); long long N; cin >> N; string ans = solve(N); cout << ans << endl; } string solve(long long int N) { stringstream ss; if (N >= 50) return "000000000000"; unsigned long long ans = 1; for (auto i = 2; i <= N; ++i) { ans *= i; ans %= 1000000000000; } if (N >= 15) ss << setw(12) << setfill('0') << ans; else ss << ans; return ss.str(); }