結果

問題 No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
ユーザー GER_chenGER_chen
提出日時 2021-01-22 22:15:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 503 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 10,920 KB
実行使用メモリ 12,460 KB
最終ジャッジ日時 2023-08-27 19:38:02
合計ジャッジ時間 4,461 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
12,460 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 16 ms
8,048 KB
testcase_05 AC 16 ms
7,936 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 TLE -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#yuki-1358
from math import gcd
mod = 10**9+7
T = int(input())  #20以下

#testcases
for _ in range(T):
    N, K, H, Y = map(int, input().split())
    g = gcd(K, H)
    h = gcd(N, g)
    if Y%h:
        print(0)
    else:
        N, K, H, Y = N//h, K//h, H//h, Y//h
        rev = pow(K,-1, H)
        ans, i = 0, 0
        if g > 1:
            i = Y*pow(N, -1, g)%g
        while N*i <= Y:
            ans += ((Y-i*N)//K-rev*(Y-i*N)%H)//H+1
            ans %= mod
            i += g
        print(ans)
0