結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int n,ans[20],flag,len=1;
signed main() 
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
    cin>>n;
    if(n>=60)
    {
        puts("000000000000");
        return 0;
    }
    ans[1]=1;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=12;j++) ans[j]*=i;
        for(int j=1;j<=12;j++)
        {
            if(ans[j]>=10) len=max(len,j+1);
            ans[j+1]+=ans[j]/10;
            ans[j]%=10;
            flag&=(ans[j]==0);
        }
        if(flag) break;
    }
    len=min(len,12LL);
    for(int i=len;i>=1;i--) cout<<ans[i];
    return 0;
}
0