結果

問題 No.2699 Simple Math (Returned)
ユーザー planesplanes
提出日時 2024-03-29 22:01:15
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 385 ms / 2,000 ms
コード長 2,210 bytes
コンパイル時間 1,815 ms
コンパイル使用メモリ 167,524 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-29 22:01:23
合計ジャッジ時間 7,420 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 299 ms
6,676 KB
testcase_02 AC 359 ms
6,676 KB
testcase_03 AC 301 ms
6,676 KB
testcase_04 AC 385 ms
6,676 KB
testcase_05 AC 347 ms
6,676 KB
testcase_06 AC 336 ms
6,676 KB
testcase_07 AC 374 ms
6,676 KB
testcase_08 AC 371 ms
6,676 KB
testcase_09 AC 375 ms
6,676 KB
testcase_10 AC 370 ms
6,676 KB
testcase_11 AC 375 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


template<int mod> 
class modint {
    long long x;
public:
    modint(long long x=0) : x((x%mod+mod)%mod) {}
    modint operator-() const { 
      return modint(-x);
    }
    modint& operator+=(const modint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator-=(const modint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    modint& operator*=(const  modint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    modint operator+(const modint& a) const {
        modint res(*this);
        return res+=a;
    }
    modint operator-(const modint& a) const {
        modint res(*this);
        return res-=a;
    }
    modint operator*(const modint& a) const {
        modint res(*this);
        return res*=a;
    }
    modint pow(ll t) const {
        if (!t) return 1;
        modint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    modint inv() const {
        return pow(mod-2);
    }
    modint& operator/=(const modint& a) {
        return (*this) *= a.inv();
    }
    modint operator/(const modint& a) const {
        modint res(*this);
        return res/=a;
    }

    bool operator==(const modint &a) const {
        modint res(*this);
        return res.x==a.x;
    }

    bool operator!=(const modint &a) const {
        modint res(*this);
        return res.x!=a.x;
    }


    friend ostream& operator<<(ostream& os, const modint& m){
        os << m.x;
        return os;
    }
};

using mint=modint<998244353>;



ll mod_pow(ll x,ll n,ll mod) {
ll res=1;
  while(n>0) {
if(n&1) {
res=res*x%mod;
}
   x=x*x%mod;
    n>>=1;
  }
return res;
}
 

void solve() {
ll N,M;cin>>N>>M;
N%=(2*M);

ll k=max(0LL,N-(M+1)+1);

ll noko=N-2*k;
mint ans=mod_pow(10,noko,998244353);
ans-=1;

ans*=mod_pow(10,k,998244353);

cout<<ans<<endl;

}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll t;cin>>t;
  for(ll i=0;i<t;i++) {
    solve();
  }

}


  
0