結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
12,316 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 AC 16 ms
7,980 KB
testcase_05 AC 17 ms
7,940 KB
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 TLE -
testcase_13 RE -
testcase_14 TLE -
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
        if g > 1:
            ini = Y*pow(N, -1, g)%g
            ans = 0
            while N*ini <= Y:
                ans += ((Y-i*N)//K-rev*(Y-i*N)%H)//H+1
                ans %= mod
                ini += g
            print(ans)
        if g == 1:
            rev = pow(K,-1, H)
            ans = sum(((Y-i*N)//K-rev*(Y-i*N)%H)//H+1 for i in range(Y//N+1))
            print(ans)
0