結果

問題 No.500 階乗電卓
ユーザー chocorusk
提出日時 2018-10-17 07:02:51
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 805 bytes
コンパイル時間 776 ms
コンパイル使用メモリ 90,528 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-12 18:50:47
合計ジャッジ時間 1,494 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e12;
int main()
{
	ll n;
	cin>>n;
	if(n>=50){
	    cout<<"000000000000"<<endl;
	}else{
	    ll ans=1;
	    for(ll i=2; i<=n; i++){
	        ans*=i;
	        ans%=MOD;
	    }
	    if(n<15){
	        cout<<ans<<endl;
	    }else{
	        int d=0;
	        ll ans1=ans;
	        while(ans1>0){
	            d++;
	            ans1/=10;
	        }
	        for(int i=0; i<12-d; i++) cout<<'0';
	        cout<<ans<<endl;
	    }
	}
	return 0;
}
0