結果

問題 No.3398 Accuracy of Integer Division Approximate Function 2
コンテスト
ユーザー 👑 amentorimaru
提出日時 2025-11-29 19:01:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 711 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 269 ms
コンパイル使用メモリ 82,172 KB
実行使用メモリ 89,664 KB
最終ジャッジ日時 2025-12-04 23:33:39
合計ジャッジ時間 4,822 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 3
other AC * 5 WA * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import sys
input = sys.stdin.readline
def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
from fractions import Fraction

# サンプルの時点で違うが、一応これは出すべきと思うので
def main():
  [d,a,b,k]=read_list()
  def calc(x):
    return x//d-(x//a*(a*b//d)//b)
  t=calc(10**100)
  if t <= k:
    print(-1)    
    return
  l=-1
  r=10**64
  while l+1<r:
    m=(l+r)//2
    md=m*d
    if calc(md) > k:
      r=m
    else:
      l=m
  print(r*d)        
  return        
        
      
if __name__ == "__main__":
  t=int(input())
  for _ in range(t):
    main()
    
    
0