結果
問題 | No.2649 [Cherry 6th Tune C] Anthem Flower |
ユーザー |
|
提出日時 | 2025-04-22 08:56:16 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 694 ms / 2,000 ms |
コード長 | 432 bytes |
コンパイル時間 | 309 ms |
コンパイル使用メモリ | 82,224 KB |
実行使用メモリ | 78,272 KB |
最終ジャッジ日時 | 2025-04-22 08:56:27 |
合計ジャッジ時間 | 10,397 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
T = int(input()) for _ in range(T): N,M = input().split() M = int(M) K = len(N) cnt = 0 if int(N[-1])%2==0: for i in range(K-1): cnt = (cnt*10+5*int(N[i]))%M cnt = (cnt+int(N[-1])//2)%M ans = (cnt*(2*cnt+1))%M else: for i in range(K-1): cnt = (cnt*10+5*int(N[i]))%M cnt = (cnt+(int(N[-1])+1)//2)%M ans = (cnt*(2*cnt-1))%M print(ans)