結果

問題 No.500 階乗電卓
ユーザー WA_TLE
提出日時 2017-04-07 22:42:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 290 ms
コンパイル使用メモリ 22,400 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 02:50:11
合計ジャッジ時間 945 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:4:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    4 |         scanf("%lld",&N);
      |         ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int main(void){
	long long int N,ans=1,ok=0;
	scanf("%lld",&N);
	if(N<1000){
		for(;N>1;N--){
			ans*=N;
			if(ans>=1000000000000){
				ok=1;
			}
			ans%=1000000000000;
		}
		if(ok==0){ printf("%lld\n",ans); } else{
			printf("%012lld\n",ans);
		}
	} else{
		printf("000000000000\n");
	}
	return 0;
}
0