結果
| 問題 |
No.3304 INCREASE decrease
|
| コンテスト | |
| ユーザー |
ゼット
|
| 提出日時 | 2025-10-05 14:54:17 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 657 ms / 2,000 ms |
| コード長 | 548 bytes |
| コンパイル時間 | 159 ms |
| コンパイル使用メモリ | 82,400 KB |
| 実行使用メモリ | 81,056 KB |
| 最終ジャッジ日時 | 2025-10-05 14:54:35 |
| 合計ジャッジ時間 | 13,835 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 30 |
ソースコード
Q=int(input())
for _ in range(Q):
N,K=map(int,input().split())
N-=1
result=0
mod=998244353
M=10**K
p=M//2
w=M*p-p*(1+p)
t=N//M
if t>=2:
s=t//2
w*=t*s-s*(s+1)
w%=mod
result+=w
result%=mod
pos=N%M
l=0
r=p
while True:
m=(l+r+1)//2
score=M-2*m
if score>pos:
l=m
else:
r=m-1
if l==r:
break
q=0
q+=l*(pos+1)
q%=mod
count=p-l
q+=M*count
q%=mod
q-=count*(l+1+p)
q%=mod
result+=q*s
result%=mod
print(result)
ゼット