結果

問題 No.500 階乗電卓
コンテスト
ユーザー fura
提出日時 2020-05-04 18:01:38
言語 C++17
(gcc 13.3.0 + boost 1.89.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 382 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,464 ms
コンパイル使用メモリ 191,180 KB
最終ジャッジ日時 2025-01-10 06:25:36
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;
using lint=long long;

int main(){
	lint n; cin>>n;

	if(n>=50){
		puts("000000000000");
		return 0;
	}

	lint ans=1;
	bool over=false;
	rep(i,n){
		ans*=i+1;
		if(ans>=1e12) over=true;
		ans%=1000000000000LL;
	}
	if(over) printf("%012lld\n",ans);
	else     printf("%lld\n",ans);

	return 0;
}
0