結果
問題 | No.502 階乗を計算するだけ |
ユーザー | 37zigen |
提出日時 | 2017-04-07 23:22:04 |
言語 | Java21 (openjdk 21) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,975 bytes |
コンパイル時間 | 2,032 ms |
コンパイル使用メモリ | 77,960 KB |
実行使用メモリ | 54,452 KB |
最終ジャッジ日時 | 2024-07-16 03:04:03 |
合計ジャッジ時間 | 10,021 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 123 ms
53,912 KB |
testcase_01 | AC | 121 ms
54,076 KB |
testcase_02 | AC | 124 ms
54,452 KB |
testcase_03 | AC | 110 ms
53,028 KB |
testcase_04 | AC | 106 ms
52,884 KB |
testcase_05 | AC | 124 ms
54,140 KB |
testcase_06 | AC | 122 ms
54,044 KB |
testcase_07 | AC | 122 ms
54,184 KB |
testcase_08 | AC | 120 ms
53,840 KB |
testcase_09 | AC | 119 ms
54,200 KB |
testcase_10 | AC | 123 ms
54,136 KB |
testcase_11 | AC | 122 ms
54,128 KB |
testcase_12 | AC | 124 ms
54,048 KB |
testcase_13 | AC | 120 ms
54,272 KB |
testcase_14 | AC | 126 ms
54,168 KB |
testcase_15 | AC | 119 ms
53,780 KB |
testcase_16 | AC | 122 ms
54,308 KB |
testcase_17 | AC | 125 ms
54,280 KB |
testcase_18 | AC | 125 ms
53,992 KB |
testcase_19 | AC | 128 ms
53,848 KB |
testcase_20 | AC | 124 ms
54,016 KB |
testcase_21 | AC | 113 ms
52,780 KB |
testcase_22 | AC | 144 ms
54,248 KB |
testcase_23 | AC | 132 ms
54,016 KB |
testcase_24 | AC | 125 ms
54,260 KB |
testcase_25 | AC | 145 ms
53,904 KB |
testcase_26 | AC | 122 ms
53,200 KB |
testcase_27 | AC | 128 ms
54,324 KB |
testcase_28 | AC | 130 ms
54,160 KB |
testcase_29 | AC | 129 ms
54,444 KB |
testcase_30 | AC | 140 ms
54,320 KB |
testcase_31 | AC | 134 ms
54,204 KB |
testcase_32 | RE | - |
testcase_33 | RE | - |
testcase_34 | RE | - |
testcase_35 | RE | - |
testcase_36 | RE | - |
testcase_37 | RE | - |
testcase_38 | RE | - |
testcase_39 | RE | - |
testcase_40 | AC | 139 ms
54,204 KB |
testcase_41 | RE | - |
testcase_42 | AC | 112 ms
53,524 KB |
testcase_43 | AC | 122 ms
53,952 KB |
testcase_44 | AC | 122 ms
53,908 KB |
testcase_45 | AC | 118 ms
53,800 KB |
testcase_46 | AC | 123 ms
54,076 KB |
testcase_47 | AC | 120 ms
54,252 KB |
testcase_48 | AC | 124 ms
53,920 KB |
testcase_49 | AC | 119 ms
53,920 KB |
testcase_50 | AC | 118 ms
54,140 KB |
testcase_51 | AC | 108 ms
53,072 KB |
ソースコード
import java.util.ArrayDeque; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { new Main().run(); } void run() { Scanner sc = new Scanner(System.in); long n = sc.nextLong(); long mod = (long) (1e9 + 7); if (n >= mod) { System.out.println(0); return; } long[] pre = new long[] { 1, 641102369, 578095319, 5832229, 259081142, 974067448, 316220877, 690120224, 251368199, 980250487, 682498929, 134623568, 95936601, 933097914, 167332441, 598816162, 336060741, 248744620, 626497524, 288843364, 491101308, 245341950, 565768255, 246899319, 968999, 586350670, 638587686, 881746146, 19426633, 850500036, 76479948, 268124147, 842267748, 886294336, 485348706, 463847391, 544075857, 898187927, 798967520, 82926604, 723816384, 156530778, 721996174, 299085602, 323604647, 172827403, 398699886, 530389102, 294587621, 813805606, 67347853, 497478507, 196447201, 722054885, 228338256, 407719831, 762479457, 746536789, 811667359, 778773518, 27368307, 438371670, 59469516, 5974669, 766196482, 606322308, 86609485, 889750731, 340941507, 371263376, 625544428, 788878910, 808412394, 996952918, 585237443, 1669644, 361786913, 480748381, 595143852, 837229828, 199888908, 526807168, 579691190, 145404005, 459188207, 534491822, 439729802, 840398449, 899297830, 235861787, 888050723, 656116726, 736550105, 440902696, 85990869, 884343068, 56305184, 973478770, 168891766, 804805577, 927880474, 876297919, 934814019, 676405347, 567277637, 112249297, 44930135, 39417871, 47401357, 108819476, 281863274, 60168088, 692636218, 432775082, 14235602, 770511792, 400295761, 697066277, 421835306, 220108638 }; int q = (int) (n / (1e6)); long cur = pre[q]; n %= (1e6); for (long i = (long) ((1e6) * q + 1); i <= 1e6 * q + n; ++i) { cur = (cur * i) % mod; } System.out.println(cur); } void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }