結果

問題 No.2699 Simple Math (Returned)
ユーザー navel_tosnavel_tos
提出日時 2024-03-29 22:59:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 802 ms / 2,000 ms
コード長 573 bytes
コンパイル時間 390 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 76,156 KB
最終ジャッジ日時 2024-03-29 23:00:05
合計ジャッジ時間 10,129 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 533 ms
75,904 KB
testcase_02 AC 690 ms
75,900 KB
testcase_03 AC 540 ms
75,900 KB
testcase_04 AC 802 ms
76,028 KB
testcase_05 AC 657 ms
75,900 KB
testcase_06 AC 655 ms
75,900 KB
testcase_07 AC 746 ms
76,152 KB
testcase_08 AC 780 ms
76,152 KB
testcase_09 AC 774 ms
76,156 KB
testcase_10 AC 742 ms
76,156 KB
testcase_11 AC 770 ms
76,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#yukicoder424A Simple Math(Returned)

MOD = 998244353

#実験
def brute(N, M):
    return ((10 ** N - 1) % (10 ** M + 1)) % MOD
    
#見えた規則性に沿って実装
def brute2(N, M):
    N %= 2 * M
    if N <= M:
        return (10 ** N - 1) % MOD
    else:
        return (10 ** M - 10 ** (N - M)) % MOD

def solve(N, M):
    N %= 2 * M
    if N <= M:
        return (pow(10, N, MOD) - 1) % MOD
    else:
        return (pow(10, M, MOD) - pow(10, N - M, MOD)) % MOD
    
for _ in range( int(input()) ):
    N, M = map(int, input().split())
    print( solve(N, M) )
0