結果

問題 No.129 お年玉(2)
ユーザー rlangevinrlangevin
提出日時 2023-02-11 01:55:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 499 ms / 5,000 ms
コード長 826 bytes
コンパイル時間 591 ms
コンパイル使用メモリ 87,244 KB
実行使用メモリ 78,312 KB
最終ジャッジ日時 2023-09-22 02:10:09
合計ジャッジ時間 12,751 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
77,888 KB
testcase_01 AC 499 ms
78,236 KB
testcase_02 AC 95 ms
71,816 KB
testcase_03 AC 95 ms
71,956 KB
testcase_04 AC 94 ms
71,716 KB
testcase_05 AC 251 ms
78,028 KB
testcase_06 AC 220 ms
77,764 KB
testcase_07 AC 293 ms
78,032 KB
testcase_08 AC 311 ms
77,832 KB
testcase_09 AC 193 ms
78,268 KB
testcase_10 AC 323 ms
78,168 KB
testcase_11 AC 228 ms
77,892 KB
testcase_12 AC 127 ms
77,996 KB
testcase_13 AC 119 ms
78,068 KB
testcase_14 AC 228 ms
78,044 KB
testcase_15 AC 206 ms
77,752 KB
testcase_16 AC 241 ms
77,864 KB
testcase_17 AC 183 ms
77,952 KB
testcase_18 AC 295 ms
77,924 KB
testcase_19 AC 371 ms
78,244 KB
testcase_20 AC 262 ms
78,092 KB
testcase_21 AC 197 ms
78,112 KB
testcase_22 AC 253 ms
77,892 KB
testcase_23 AC 309 ms
78,180 KB
testcase_24 AC 417 ms
78,236 KB
testcase_25 AC 230 ms
77,984 KB
testcase_26 AC 277 ms
77,940 KB
testcase_27 AC 269 ms
77,916 KB
testcase_28 AC 262 ms
78,056 KB
testcase_29 AC 95 ms
71,840 KB
testcase_30 AC 97 ms
71,628 KB
testcase_31 AC 97 ms
71,684 KB
testcase_32 AC 97 ms
71,716 KB
testcase_33 AC 105 ms
76,676 KB
testcase_34 AC 107 ms
77,264 KB
testcase_35 AC 103 ms
77,136 KB
testcase_36 AC 110 ms
77,620 KB
testcase_37 AC 106 ms
77,336 KB
testcase_38 AC 133 ms
78,104 KB
testcase_39 AC 132 ms
77,904 KB
testcase_40 AC 166 ms
77,924 KB
testcase_41 AC 189 ms
77,828 KB
testcase_42 AC 152 ms
77,856 KB
testcase_43 AC 118 ms
77,932 KB
testcase_44 AC 448 ms
78,232 KB
testcase_45 AC 137 ms
77,912 KB
testcase_46 AC 117 ms
77,784 KB
testcase_47 AC 376 ms
78,312 KB
testcase_48 AC 311 ms
77,976 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import *
from collections import *

def Sieve(n):
    lst = [True] * (n + 1)
    S = set()
    for i in range(2, ceil(sqrt(n)) + 1):
        if lst[i]:
            for j in range(2 * i, n + 1, i):
                lst[j] = False
    for i in range(2, n + 1):
        if lst[i]:
            S.add(i)
    return S


N = int(input())//1000
M = int(input())
r = N % M
ans = 1
mod = 10 ** 9
inv = 1
seen = [0] * (r + 1)
P = Sieve(M)
D = defaultdict(int)
for p in P:
    now = p
    while True:
        D[p] += r//now
        now *= p
        if M // now == 0:
            break

for i in range(r):
    now = M - i
    for k, v in D.items():
        while D[k]:
            if now % k == 0:
                now //= k
                D[k] -= 1
            else:
                break
    ans *= now
    ans %= mod
print(ans)
0