結果

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

ソースコード

diff #
raw source code

def count(st):
    if st<=0:
        return 0
    if st%2==1:
        return count(st-1)+st//2
    sm=st*(st+1)//2
    sm-=st//2
    return sm//2

T=int(input())
for _ in range(T):
    N,K=map(int,input().split())
    N-=1
    nt=N//pow(10,K)
    nb=N%pow(10,K)
    ans=count(nt-1)*count(pow(10,K)-1)
    ls=nt//2
    ls*=count(pow(10,K)-1)-count(pow(10,K)-2-nb)
    print((ans+ls)%998244353)
0