結果

問題 No.500 階乗電卓
ユーザー YamaKasaYamaKasa
提出日時 2018-09-24 15:41:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 3,412 ms
コンパイル使用メモリ 75,028 KB
実行使用メモリ 58,120 KB
最終ジャッジ日時 2023-10-22 02:46:33
合計ジャッジ時間 6,452 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 134 ms
57,388 KB
testcase_05 AC 136 ms
57,364 KB
testcase_06 AC 132 ms
57,368 KB
testcase_07 AC 134 ms
57,368 KB
testcase_08 AC 133 ms
57,356 KB
testcase_09 AC 130 ms
56,972 KB
testcase_10 AC 132 ms
57,352 KB
testcase_11 AC 133 ms
57,260 KB
testcase_12 AC 132 ms
57,336 KB
testcase_13 AC 132 ms
57,244 KB
testcase_14 AC 138 ms
57,440 KB
testcase_15 AC 134 ms
57,548 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 Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();
		scan.close();
		long x = 1;
		if(N >= 50) {
			System.out.println(000000000000);
			System.exit(0);
		}
		for(int i = 1; i <= N; i++) {
			x = x * i;
			String n = Long.toString(x);
			if(n.length() > 15) {
				x = Long.parseLong(n.substring(n.length() - 15, n.length()));
			}
		}
		String ans = Long.toString(x);
		if(ans.length() > 12) {
			ans = ans.substring(ans.length() - 12, ans.length());
		}
		System.out.println(ans);
	}
}
0