結果
| 問題 |
No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
|
| コンテスト | |
| ユーザー |
yuusanlondon
|
| 提出日時 | 2021-01-22 23:48:12 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 456 bytes |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 21,504 KB |
| 最終ジャッジ日時 | 2024-12-28 09:36:08 |
| 合計ジャッジ時間 | 20,197 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 11 TLE * 6 |
ソースコード
import math
t=int(input())
MOD=10**9+7
for _ in range(t):
n,k,h,y=map(int,input().split())
r=[n,k,h]
r.sort()
ans=0
p=math.gcd(r[0],r[1])
k=r[0]//p
q=r[1]//p
a=pow(k,-1,q)
b=(1-a*k)//q
while a<0:
a+=q
b-=k
while b<0:
b+=k
a-=q
for i in range(0,y,r[2]):
tmp=y-i
if tmp%p:
continue
tmp=tmp//p
ans=(ans+(b*tmp*p)//k-(-a*tmp*p)//q)%MOD
if (b*tmp*p)%k:
ans=(ans+1)%MOD
print(ans)
yuusanlondon