結果
問題 | No.1358 [Zelkova 2nd Tune *] 語るなら枚数を... |
ユーザー | GER_chen |
提出日時 | 2021-01-22 22:10:50 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 647 bytes |
コンパイル時間 | 319 ms |
コンパイル使用メモリ | 10,876 KB |
実行使用メモリ | 12,704 KB |
最終ジャッジ日時 | 2023-08-27 19:28:53 |
合計ジャッジ時間 | 7,142 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 59 ms
12,372 KB |
testcase_01 | RE | - |
testcase_02 | RE | - |
testcase_03 | RE | - |
testcase_04 | AC | 17 ms
8,016 KB |
testcase_05 | AC | 17 ms
8,116 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 | -- | - |
ソースコード
#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) 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: ans = sum(((Y-i*N)//K-rev*(Y-i*N)%H)//H+1 for i in range(Y//N+1)) print(ans)