結果

問題 No.2699 Simple Math (Returned)
ユーザー KeeKee
提出日時 2024-03-30 17:24:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 439 ms / 2,000 ms
コード長 1,196 bytes
コンパイル時間 616 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 78,468 KB
最終ジャッジ日時 2024-03-30 17:25:04
合計ジャッジ時間 6,368 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
55,608 KB
testcase_01 AC 149 ms
78,468 KB
testcase_02 AC 311 ms
76,804 KB
testcase_03 AC 148 ms
78,468 KB
testcase_04 AC 439 ms
76,940 KB
testcase_05 AC 277 ms
76,932 KB
testcase_06 AC 226 ms
77,060 KB
testcase_07 AC 398 ms
76,812 KB
testcase_08 AC 369 ms
76,932 KB
testcase_09 AC 370 ms
77,060 KB
testcase_10 AC 395 ms
76,932 KB
testcase_11 AC 368 ms
76,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/python3

import bisect
import collections
import heapq
import itertools
import math
import os
import sys


MOD = 998244353


def main():
    for _ in range(read_int()):
        n, m = read_ints()
        n %= 2 * m
        if n <= m:
            print((pow(10, n, MOD) - 1) % MOD)
        else:
            b = (pow(10, m, MOD) + 1) % MOD
            print((b - 1 - pow(10, n - m, MOD)) % MOD)


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def list2d(d1, d2, init=None):
    return [[init] * d2 for _ in range(d1)]


def list3d(d1, d2, d3, init=None):
    return [[[init] * d3 for _ in range(d2)] for _ in range(d1)]


def list4d(d1, d2, d3, d4, init=None):
    return [[[[init] * d4 for _ in range(d3)] for _ in range(d2)]
            for _ in range(d1)]


def debug(fmt, *args):
    if DEBUG:
        if args:
            print(fmt.format(*args), file=sys.stderr)
        else:
            print(fmt, file=sys.stderr)


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