結果
問題 | No.500 階乗電卓 |
ユーザー | YamaKasa |
提出日時 | 2018-09-24 15:42:19 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 121 ms / 2,000 ms |
コード長 | 595 bytes |
コンパイル時間 | 2,790 ms |
コンパイル使用メモリ | 75,000 KB |
実行使用メモリ | 57,840 KB |
最終ジャッジ日時 | 2023-10-22 02:47:55 |
合計ジャッジ時間 | 6,487 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 117 ms
57,764 KB |
testcase_01 | AC | 103 ms
56,428 KB |
testcase_02 | AC | 108 ms
56,448 KB |
testcase_03 | AC | 115 ms
57,596 KB |
testcase_04 | AC | 116 ms
57,512 KB |
testcase_05 | AC | 103 ms
56,228 KB |
testcase_06 | AC | 105 ms
56,232 KB |
testcase_07 | AC | 114 ms
57,376 KB |
testcase_08 | AC | 112 ms
57,164 KB |
testcase_09 | AC | 99 ms
55,972 KB |
testcase_10 | AC | 113 ms
57,240 KB |
testcase_11 | AC | 114 ms
57,368 KB |
testcase_12 | AC | 100 ms
55,952 KB |
testcase_13 | AC | 112 ms
57,440 KB |
testcase_14 | AC | 112 ms
57,532 KB |
testcase_15 | AC | 115 ms
57,376 KB |
testcase_16 | AC | 118 ms
57,440 KB |
testcase_17 | AC | 121 ms
57,384 KB |
testcase_18 | AC | 117 ms
57,840 KB |
testcase_19 | AC | 120 ms
57,668 KB |
testcase_20 | AC | 110 ms
57,088 KB |
testcase_21 | AC | 115 ms
57,416 KB |
testcase_22 | AC | 115 ms
57,660 KB |
ソースコード
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); } }