結果

問題 No.500 階乗電卓
ユーザー fal_rndfal_rnd
提出日時 2017-04-07 22:37:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 341 bytes
コンパイル時間 2,885 ms
コンパイル使用メモリ 71,700 KB
実行使用メモリ 58,016 KB
最終ジャッジ日時 2023-09-07 08:28:54
合計ジャッジ時間 6,433 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
55,420 KB
testcase_01 AC 111 ms
55,764 KB
testcase_02 AC 112 ms
55,936 KB
testcase_03 AC 107 ms
55,556 KB
testcase_04 AC 107 ms
55,664 KB
testcase_05 AC 109 ms
55,792 KB
testcase_06 AC 109 ms
55,880 KB
testcase_07 AC 107 ms
56,056 KB
testcase_08 AC 104 ms
55,620 KB
testcase_09 AC 111 ms
55,724 KB
testcase_10 AC 107 ms
55,544 KB
testcase_11 AC 107 ms
55,712 KB
testcase_12 AC 105 ms
55,556 KB
testcase_13 AC 110 ms
55,628 KB
testcase_14 AC 107 ms
55,580 KB
testcase_15 AC 119 ms
55,748 KB
testcase_16 AC 109 ms
55,928 KB
testcase_17 AC 108 ms
55,688 KB
testcase_18 AC 111 ms
56,064 KB
testcase_19 AC 110 ms
58,016 KB
testcase_20 AC 109 ms
56,068 KB
testcase_21 AC 111 ms
55,584 KB
testcase_22 AC 110 ms
55,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		long res=1,n=s.nextLong();
		
		boolean f=false;
		for(int i=2;i<=n&&res!=0;i++) {
			res*=i;
			
			f|=res>1000000000000L;
			res%=1000000000000L;
		}
		System.out.printf(f?"%012d\n":"%d\n",res);
	}
}
0