結果

問題 No.3304 INCREASE decrease
コンテスト
ユーザー ゼット
提出日時 2025-10-05 14:54:17
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 408 ms / 2,000 ms
+ 757µs
コード長 548 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 233 ms
コンパイル使用メモリ 95,848 KB
実行使用メモリ 88,340 KB
最終ジャッジ日時 2026-07-15 12:39:35
合計ジャッジ時間 10,533 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
0