結果

問題 No.2128 Round up!!
ユーザー nikoro256nikoro256
提出日時 2024-08-11 16:59:18
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 328 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-08-11 16:59:25
合計ジャッジ時間 6,953 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 460 ms
10,752 KB
testcase_06 AC 567 ms
10,880 KB
testcase_07 AC 525 ms
10,752 KB
testcase_08 AC 536 ms
10,880 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 469 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

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