結果
問題 | No.502 階乗を計算するだけ |
ユーザー | srup٩(๑`н´๑)۶ |
提出日時 | 2017-04-07 23:52:45 |
言語 | Python2 (2.7.18) |
結果 |
MLE
|
実行時間 | - |
コード長 | 547 bytes |
コンパイル時間 | 486 ms |
コンパイル使用メモリ | 6,676 KB |
実行使用メモリ | 813,188 KB |
最終ジャッジ日時 | 2023-09-23 03:04:17 |
合計ジャッジ時間 | 3,977 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
6,056 KB |
testcase_01 | AC | 11 ms
5,904 KB |
testcase_02 | AC | 11 ms
6,092 KB |
testcase_03 | AC | 12 ms
6,028 KB |
testcase_04 | AC | 11 ms
5,964 KB |
testcase_05 | AC | 11 ms
6,044 KB |
testcase_06 | AC | 11 ms
5,924 KB |
testcase_07 | AC | 11 ms
5,824 KB |
testcase_08 | AC | 11 ms
5,828 KB |
testcase_09 | AC | 11 ms
5,924 KB |
testcase_10 | AC | 11 ms
5,908 KB |
testcase_11 | AC | 11 ms
5,916 KB |
testcase_12 | AC | 11 ms
5,828 KB |
testcase_13 | AC | 11 ms
6,052 KB |
testcase_14 | AC | 11 ms
5,952 KB |
testcase_15 | AC | 11 ms
5,828 KB |
testcase_16 | AC | 11 ms
5,828 KB |
testcase_17 | AC | 11 ms
5,944 KB |
testcase_18 | AC | 11 ms
5,884 KB |
testcase_19 | AC | 11 ms
5,920 KB |
testcase_20 | AC | 11 ms
5,912 KB |
testcase_21 | AC | 11 ms
5,920 KB |
testcase_22 | AC | 102 ms
35,716 KB |
testcase_23 | AC | 36 ms
13,876 KB |
testcase_24 | AC | 70 ms
25,580 KB |
testcase_25 | AC | 18 ms
8,132 KB |
testcase_26 | AC | 45 ms
16,804 KB |
testcase_27 | AC | 32 ms
12,432 KB |
testcase_28 | AC | 40 ms
15,028 KB |
testcase_29 | AC | 23 ms
9,676 KB |
testcase_30 | AC | 93 ms
33,576 KB |
testcase_31 | AC | 52 ms
18,992 KB |
testcase_32 | MLE | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
testcase_41 | -- | - |
testcase_42 | -- | - |
testcase_43 | -- | - |
testcase_44 | -- | - |
testcase_45 | -- | - |
testcase_46 | -- | - |
testcase_47 | -- | - |
testcase_48 | -- | - |
testcase_49 | -- | - |
testcase_50 | -- | - |
testcase_51 | -- | - |
ソースコード
def modinv(a, m): return pow(a, m - 2, m); def factorialMod(n, modulus): ans=1 if n <= 1000000: #calculate the factorial normally (right argument of range() is exclusive) for i in range(1,n+1): ans = (ans * i) % modulus else: #Fancypants method for large n for i in range(n+1,modulus): ans = (ans * i) % modulus ans = modinv(ans, modulus) ans = -1*ans + modulus return ans % modulus mod = 1000000007; k = raw_input() print factorialMod(int(k), mod)