結果

問題 No.500 階乗電卓
ユーザー vjudge1
提出日時 2025-06-19 19:31:59
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 604 bytes
コンパイル時間 1,652 ms
コンパイル使用メモリ 163,832 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-19 19:32:02
合計ジャッジ時間 2,652 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

# include <bits/stdc++.h>
# define int long long
# define FILE(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
using namespace std;
const int mod = 1e12;
int n;
int ans = 1;
signed main()
{
    //FILE("factorial");
    cin >> n;
    if (n >= 50)
    {
        for (int i = 1; i <= 12; i ++)
        {
            cout << 0;
        }
        return 0;
    }
    for (int i = 1; i <= n; i ++)
    {
        ans = ans * i % mod;
    }
    string s = to_string(ans);
    while (s.size() < 12)
    {
        s = "0" + s;
    }
    if (n >= 15) cout << s;
    else cout << ans;
    return 0;
}
0