結果

問題 No.500 階乗電卓
ユーザー dnish
提出日時 2017-07-06 01:58:00
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 1,635 ms
コンパイル使用メモリ 167,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 03:02:41
合計ジャッジ時間 2,327 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n,N) for(ll i=(n);i<(ll) N;i++)
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;

int main(){
	int N;
	cin>>N;
	ll ans=1;
	int mx=0;
	if(N<50){
		REP(i,1,N+1){
			ans*=i;
			ans%=1000000000000;
			mx=max<int>(mx,to_string(ans).size());
		}
		string s=to_string(ans);
		REP(i,0,mx-s.size()) cout<<'0';
		printf("%lld\n",ans);
	}
	else{
		printf("000000000000\n");
	}
	return 0;
}
0