結果

問題 No.502 階乗を計算するだけ
ユーザー ntuda
提出日時 2025-08-23 23:14:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 335 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 82,724 KB
実行使用メモリ 67,504 KB
最終ジャッジ日時 2025-08-23 23:14:21
合計ジャッジ時間 3,972 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
dic = defaultdict(int)
MOD = 10 ** 9 + 7
n = int(input())
tmp = 1
X = [1]
for i in range(1,21008):
    tmp *= i
    tmp %= MOD
    if tmp in dic:
        print(i,tmp,dic[tmp],i-dic[tmp])
        break
    dic[tmp] = i
    X.append(tmp)

if n >= 21008:
    n = (n - 11448) % 9560 + 11448
print(X[n])
0