結果

問題 No.2699 Simple Math (Returned)
ユーザー aa
提出日時 2024-03-29 22:35:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 849 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 407 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 77,376 KB
最終ジャッジ日時 2024-03-29 22:35:27
合計ジャッジ時間 10,470 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 541 ms
76,140 KB
testcase_02 AC 722 ms
76,864 KB
testcase_03 AC 544 ms
75,876 KB
testcase_04 AC 849 ms
77,000 KB
testcase_05 AC 688 ms
77,008 KB
testcase_06 AC 648 ms
76,120 KB
testcase_07 AC 811 ms
77,376 KB
testcase_08 AC 838 ms
77,248 KB
testcase_09 AC 839 ms
77,248 KB
testcase_10 AC 795 ms
77,120 KB
testcase_11 AC 802 ms
77,376 KB
権限があれば一括ダウンロードができます

ソースコード

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))%998244353)
    else:
        print((fast_exponentiation(10, k, 998244353)-1)%998244353)
    #print((10**n-1)%(10**m+1)%998244353)
0