結果

問題 No.500 階乗電卓
ユーザー keisuke6
提出日時 2022-07-13 09:44:03
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 465 bytes
コンパイル時間 3,236 ms
コンパイル使用メモリ 243,736 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-24 08:42:15
合計ジャッジ時間 3,691 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
int f(int x){
  int ans = 0;
  while(x != 0){
    ans++;
    x /= 10;
  } 
  return ans;
}
signed main(){
  int N;
  cin>>N;
  if(N >= 50) cout<<"000000000000"<<endl;
  else{
    int ans = 1;
    bool ok = false;
    for(int i=1;i<=N;i++){
      ans *= i;
      if(ans >= 1e12) ok = true;
      ans %= 1000000000000;
    }
    if(ok)for(int i=0;i<12-f(ans);i++) cout<<0;
    cout<<ans<<endl;
  }
}
0