結果
問題 |
No.2066 Simple Math !
|
ユーザー |
![]() |
提出日時 | 2022-09-16 10:47:08 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 689 bytes |
コンパイル時間 | 310 ms |
コンパイル使用メモリ | 82,132 KB |
実行使用メモリ | 77,368 KB |
最終ジャッジ日時 | 2024-12-21 06:09:26 |
合計ジャッジ時間 | 25,291 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 21 WA * 10 |
ソースコード
from math import gcd def floor_sum(n,m,a,b): ans=0 while True: if a>=m: ans+=(n-1)*n*(a//m)//2 a%=m if b>=m: ans+=n*(b//m) b%=m y_max=(a*n+b)//m x_max=(y_max*m-b) if y_max==0: return ans ans+=(n-(x_max+a-1)//a)*y_max n,m,a,b=y_max,a,m,(a-x_max%a)%a T = int(input()) for _ in range(T): P,Q,K=map(int,input().split()) ok = 10 ** 18 ng = 0 def isok(z): r = z//P if floor_sum(r+1,Q,P,Q+z-P*r)-1>= K: return True else: return False while ok -ng > 1: z = (ok+ng)>>1 if isok(z): ok = z else: ng = z print(ok)