結果
| 問題 | No.3304 INCREASE decrease | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-10-05 16:24:57 | 
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 66 ms / 2,000 ms | 
| コード長 | 791 bytes | 
| コンパイル時間 | 2,813 ms | 
| コンパイル使用メモリ | 278,576 KB | 
| 実行使用メモリ | 7,720 KB | 
| 最終ジャッジ日時 | 2025-10-05 16:25:08 | 
| 合計ジャッジ時間 | 5,995 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 30 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#include<atcoder/modint>
using namespace atcoder;
using mint=modint998244353;
mint f(ll M){//0<=x<y<z<M の等差数列
    mint res=0;
    M--;
    if(M%2==0){
        res+=M/2;
    }
    M=(M-1)/2;
    res+=mint(M)*mint(M+1);
    return res;
}
mint g(ll M,ll m){
    mint res=mint(M)*mint(m);
    res-=mint(m)*mint(m+1)/mint(2);
    res-=((M)/2+1)-((M-m)/2+1);
    res/=mint(2);
    return res;
}
void solve(){
    ll N,K;
    cin>>N>>K;
    ll r=1;
    for(int i=0;i<K;i++)r*=10;
    ll up=N/r;
    ll dw=N%r;
    mint an=f(up)*f(r);
    mint bn=g(r,dw)*mint(up/2);
    cout<<(an+bn).val()<<"\n";
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll T;
    cin>>T;
    while(T--)solve();
}  
            
            
            
        