結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
ユーザー lloyzlloyz
提出日時 2024-03-08 00:39:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,019 ms / 2,000 ms
コード長 597 bytes
コンパイル時間 253 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 143,452 KB
最終ジャッジ日時 2024-03-08 00:39:48
合計ジャッジ時間 13,696 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,460 KB
testcase_01 AC 767 ms
75,840 KB
testcase_02 AC 766 ms
75,840 KB
testcase_03 AC 771 ms
75,844 KB
testcase_04 AC 720 ms
75,844 KB
testcase_05 AC 992 ms
75,968 KB
testcase_06 AC 1,019 ms
75,968 KB
testcase_07 AC 112 ms
75,840 KB
testcase_08 AC 113 ms
75,840 KB
testcase_09 AC 78 ms
75,840 KB
testcase_10 AC 81 ms
75,840 KB
testcase_11 AC 48 ms
62,228 KB
testcase_12 AC 46 ms
62,228 KB
testcase_13 AC 160 ms
122,184 KB
testcase_14 AC 158 ms
123,848 KB
testcase_15 AC 149 ms
120,528 KB
testcase_16 AC 153 ms
115,648 KB
testcase_17 AC 154 ms
143,452 KB
testcase_18 AC 150 ms
128,524 KB
testcase_19 AC 151 ms
126,592 KB
testcase_20 AC 155 ms
130,920 KB
testcase_21 AC 151 ms
134,764 KB
testcase_22 AC 155 ms
126,228 KB
testcase_23 AC 143 ms
130,848 KB
testcase_24 AC 142 ms
130,848 KB
testcase_25 AC 144 ms
130,844 KB
testcase_26 AC 144 ms
130,848 KB
testcase_27 AC 143 ms
130,848 KB
testcase_28 AC 141 ms
130,848 KB
testcase_29 AC 143 ms
130,848 KB
testcase_30 AC 144 ms
130,848 KB
testcase_31 AC 143 ms
130,848 KB
testcase_32 AC 144 ms
130,848 KB
testcase_33 AC 134 ms
130,848 KB
testcase_34 AC 681 ms
75,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

for _ in range(int(input())):
    n, m = input().split()
    m = int(m)
    l = len(n)
    N = []
    Pow10 = [1]
    for i in range(l):
        N.append(int(n[i]))
        Pow10.append(Pow10[-1] * 10 % m)
    L = []
    res = 0
    r = 0
    for i in range(l):
        res = r * 10 + N[i]
        q, r = divmod(res, 2)
        L.append(q)
    if N[-1] % 2 == 0:
        N[-1] += 1
    else:
        L[-1] += 1
    a, b = 0, 0
    for i in range(l):
        a += N[i] * Pow10[l - i - 1] % m
        a %= m
        b += L[i] * Pow10[l - i - 1] % m
        b %= m
    ans = a * b % m
    print(ans)
0