結果

問題 No.2699 Simple Math (Returned)
ユーザー aa
提出日時 2024-03-29 22:22:02
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 488 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 77,376 KB
最終ジャッジ日時 2024-03-29 22:22:12
合計ジャッジ時間 10,421 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 553 ms
76,140 KB
testcase_02 AC 727 ms
76,864 KB
testcase_03 AC 510 ms
75,876 KB
testcase_04 WA -
testcase_05 AC 691 ms
77,008 KB
testcase_06 AC 658 ms
76,120 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def fast_exponentiation(a, b, n):
    result = 1
    a %= n
    while b > 0:
        if b % 2 == 1:
            result = (result * a) % n
        a = (a * a) % n
        b //= 2
    return result

for _ in range(int(input())):
    n, m = map(int, input().split())
    k=n % (2 * m)
    if k>m:
        l=k-m
        k=m
        print(fast_exponentiation(10, k, 998244353)- fast_exponentiation(10, l, 998244353))
    else:
        print((fast_exponentiation(10, k, 998244353)-1)%998244353)
0