結果

問題 No.500 階乗電卓
ユーザー htensaihtensai
提出日時 2019-11-17 20:47:20
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 480 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 79,348 KB
実行使用メモリ 57,788 KB
最終ジャッジ日時 2023-10-25 21:30:05
合計ジャッジ時間 6,116 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,508 KB
testcase_01 AC 130 ms
57,512 KB
testcase_02 AC 131 ms
55,036 KB
testcase_03 AC 131 ms
57,788 KB
testcase_04 AC 131 ms
57,464 KB
testcase_05 AC 129 ms
57,436 KB
testcase_06 AC 128 ms
57,500 KB
testcase_07 AC 129 ms
57,340 KB
testcase_08 AC 134 ms
57,460 KB
testcase_09 AC 131 ms
57,620 KB
testcase_10 AC 131 ms
57,500 KB
testcase_11 AC 131 ms
57,168 KB
testcase_12 AC 128 ms
57,504 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 136 ms
57,436 KB
testcase_16 AC 130 ms
57,520 KB
testcase_17 AC 131 ms
57,608 KB
testcase_18 AC 132 ms
57,456 KB
testcase_19 AC 130 ms
57,472 KB
testcase_20 AC 131 ms
57,428 KB
testcase_21 AC 135 ms
57,452 KB
testcase_22 AC 130 ms
57,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    static final long MOD = 1000000000000L;
 	public static void main (String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		if (n < 100 && kaijo(n) != 0) {
		    System.out.println(kaijo(n));
		} else {
		    System.out.println("000000000000");
		}
	}
	
	static long kaijo (long x) {
	    if (x <= 1) {
	        return 1;
	    } else {
	        return x * kaijo(x - 1) %  MOD;
	    }
	}
}


0