結果

問題 No.2128 Round up!!
ユーザー ニックネームニックネーム
提出日時 2022-11-19 00:15:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 541 ms / 2,000 ms
コード長 316 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 11,720 KB
実行使用メモリ 10,116 KB
最終ジャッジ日時 2023-10-20 09:06:02
合計ジャッジ時間 6,709 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,100 KB
testcase_01 AC 366 ms
10,116 KB
testcase_02 AC 30 ms
10,100 KB
testcase_03 AC 402 ms
10,116 KB
testcase_04 AC 404 ms
10,116 KB
testcase_05 AC 438 ms
10,116 KB
testcase_06 AC 541 ms
10,116 KB
testcase_07 AC 479 ms
10,116 KB
testcase_08 AC 494 ms
10,116 KB
testcase_09 AC 392 ms
10,116 KB
testcase_10 AC 441 ms
10,116 KB
testcase_11 AC 440 ms
10,116 KB
testcase_12 AC 460 ms
10,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
for _ in range(int(input())):
    x, a, b = map(int, input().split())
    if a > b: a, b = b, a
    m = a*b//gcd(a, b)
    n = (x-1+m)//m*m
    c = (x-1+a)//a*a
    d = (x-1+b)//b*b
    if x == d: ans = 1
    elif x == c or d <= c: ans = 2
    else: ans = 3
    print((ans+(n-d)//b*2)%998244353)
0