結果

問題 No.1358 [Zelkova 2nd Tune *] 語るなら枚数を...
ユーザー yuusanlondonyuusanlondon
提出日時 2021-01-22 23:48:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 456 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 12,656 KB
最終ジャッジ日時 2023-08-27 23:35:00
合計ジャッジ時間 4,738 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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)
0