結果

問題 No.500 階乗電卓
ユーザー shinwisteriashinwisteria
提出日時 2017-04-08 10:36:48
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 425 bytes
コンパイル時間 3,164 ms
コンパイル使用メモリ 72,140 KB
実行使用メモリ 58,068 KB
最終ジャッジ日時 2023-09-24 23:16:09
合計ジャッジ時間 7,184 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 120 ms
55,972 KB
testcase_05 AC 120 ms
55,772 KB
testcase_06 AC 120 ms
56,412 KB
testcase_07 AC 119 ms
55,748 KB
testcase_08 AC 122 ms
55,960 KB
testcase_09 AC 119 ms
55,844 KB
testcase_10 AC 120 ms
56,232 KB
testcase_11 AC 126 ms
55,948 KB
testcase_12 AC 123 ms
56,080 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 122 ms
56,144 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Kaijocalc {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		long N = s.nextLong();
		long ans = 1;
		s.close();
		long t = (long)Math.pow(10, 12);
		for(int i = 1;i <= N;i++){
			ans *= i;
			if(ans > t){
				ans %= t;
			}
			if(ans == 0){
				break;
			}
		}
		System.out.println(ans);

	}

}
0