結果

問題 No.2649 [Cherry 6th Tune C] Anthem Flower
コンテスト
ユーザー norioc
提出日時 2024-02-24 00:46:19
言語 PyPy3
(8.0.1 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 698 ms / 2,000 ms
+ 171µs
コード長 308 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 88 ms
コンパイル使用メモリ 64,892 KB
実行使用メモリ 73,856 KB
最終ジャッジ日時 2026-10-16 18:15:16
合計ジャッジ時間 12,110 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def modulo(s: str, m: int) -> int:
    x = 0
    for d in map(int, s):
        x = (10*x + d) % m
    return x


def solve():
    n, m = input().split()
    m = int(m)

    x = modulo(n, 2*m)
    x = (x*(x+1)) % (2*m)
    assert x % 2 == 0
    print(x // 2)


T = int(input())
for _ in range(T):
    solve()
0