結果
| 問題 |
No.2128 Round up!!
|
| コンテスト | |
| ユーザー |
とりゐ
|
| 提出日時 | 2022-11-18 21:52:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 194 ms / 2,000 ms |
| コード長 | 494 bytes |
| コンパイル時間 | 156 ms |
| コンパイル使用メモリ | 82,552 KB |
| 実行使用メモリ | 77,388 KB |
| 最終ジャッジ日時 | 2024-09-20 02:15:46 |
| 合計ジャッジ時間 | 2,916 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 12 |
ソースコード
from sys import stdin
input=lambda :stdin.readline()[:-1]
from math import gcd
mod=998244353
def lcm(x,y):
return x//gcd(x,y)*y
def solve():
x,a,b=map(int,input().split())
L=lcm(a,b)
x-=(x-1)//L*L
if x==L:
print(1)
return
if a==b:
print(2)
return
a,b=min(a,b),max(a,b)
y=(L-x)//b
ans=2*y+1
nxt_a=(x+a-1)//a*a
nxt_b=(x+b-1)//b*b
if nxt_a<nxt_b:
ans+=1
if x%a!=0 and x%b!=0:
ans+=1
print(ans%mod)
for _ in range(int(input())):
solve()
とりゐ