結果

問題 No.2699 Simple Math (Returned)
ユーザー ThetaTheta
提出日時 2024-04-18 16:51:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 753 ms / 2,000 ms
コード長 1,043 bytes
コンパイル時間 532 ms
コンパイル使用メモリ 82,792 KB
実行使用メモリ 76,736 KB
最終ジャッジ日時 2024-04-18 16:52:10
合計ジャッジ時間 11,220 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,208 KB
testcase_01 AC 530 ms
76,736 KB
testcase_02 AC 631 ms
76,144 KB
testcase_03 AC 486 ms
76,192 KB
testcase_04 AC 753 ms
76,384 KB
testcase_05 AC 659 ms
76,524 KB
testcase_06 AC 575 ms
76,460 KB
testcase_07 AC 725 ms
76,432 KB
testcase_08 AC 733 ms
76,644 KB
testcase_09 AC 704 ms
76,700 KB
testcase_10 AC 739 ms
76,712 KB
testcase_11 AC 711 ms
76,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys


def printe(*args, end="\n", **kwargs):
    print(*args, end=end, file=sys.stderr, **kwargs)


def main():
    MOD = 998244353
    for _ in range(int(input())):
        N, M = map(int, input().split())
        if N <= M:
            print((pow(10, N, MOD) - 1) % MOD)
            continue
        divided_digits = N
        divisor_interval = M - 1

        # まずは確実に0で埋められるところを埋めきる
        divided_digits %= (divisor_interval + 1) * 2

        if divided_digits == 0:
            print(0)
            continue
        if divided_digits >= divisor_interval + 2:
            min_digit = divided_digits - divisor_interval
            max_digit = divided_digits - (min_digit - 1)

            print((pow(10, max_digit, MOD) - pow(10, min_digit - 1, MOD)) % MOD)
        else:
            print((pow(10, divided_digits, MOD) - 1) % MOD)
    # 11111111111
    # 1001
    # 01101111111
    # 00100111111
    # 00000011111
    # 00000001101
    # 00000000100


if __name__ == "__main__":
    main()
0