結果

問題 No.2128 Round up!!
ユーザー ニックネームニックネーム
提出日時 2022-11-18 23:00:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 543 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 621 ms
コンパイル使用メモリ 11,832 KB
実行使用メモリ 10,196 KB
最終ジャッジ日時 2023-10-20 07:59:14
合計ジャッジ時間 6,864 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,180 KB
testcase_01 AC 370 ms
10,196 KB
testcase_02 AC 30 ms
10,180 KB
testcase_03 AC 402 ms
10,196 KB
testcase_04 AC 403 ms
10,196 KB
testcase_05 AC 440 ms
10,196 KB
testcase_06 AC 543 ms
10,196 KB
testcase_07 AC 486 ms
10,196 KB
testcase_08 AC 496 ms
10,196 KB
testcase_09 AC 392 ms
10,196 KB
testcase_10 AC 441 ms
10,196 KB
testcase_11 AC 449 ms
10,196 KB
testcase_12 AC 459 ms
10,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
for _ in range(int(input())):
    x, a, b = map(int, input().split())
    if a == b: print((x%a!=0)+1); continue
    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