結果

問題 No.2128 Round up!!
ユーザー nikoro256
提出日時 2024-08-11 17:00:51
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 534 ms / 2,000 ms
コード長 327 bytes
コンパイル時間 437 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-08-11 17:00:59
合計ジャッジ時間 7,422 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
T=int(input())
p=998244353
for _ in range(T):
    X,A,B=map(int,input().split())
    A,B=max(A,B),min(A,B)
    nA=-(-X//A)*A
    nB=-(-X//B)*B
    lcm=math.lcm(A,B)
    nAB=-(-X//lcm)*lcm
    ans=1
    if nA!=X and nB!=X:
        ans+=1
    if nA>nB:
        ans+=1
    ans+=(nAB-nA)//A*2
    ans%=p
    print(ans)
0