結果

問題 No.2699 Simple Math (Returned)
ユーザー MagentorMagentor
提出日時 2023-12-08 21:18:39
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 357 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 5,055 ms
コンパイル使用メモリ 308,360 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-09 17:55:47
合計ジャッジ時間 10,126 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 289 ms
6,676 KB
testcase_02 AC 341 ms
6,676 KB
testcase_03 AC 287 ms
6,676 KB
testcase_04 AC 357 ms
6,676 KB
testcase_05 AC 330 ms
6,676 KB
testcase_06 AC 317 ms
6,676 KB
testcase_07 AC 353 ms
6,676 KB
testcase_08 AC 357 ms
6,676 KB
testcase_09 AC 338 ms
6,676 KB
testcase_10 AC 354 ms
6,676 KB
testcase_11 AC 340 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
typedef long long ll;
using mint = modint998244353;
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

void solve(){
	std::cin.tie(0)->sync_with_stdio(0);
  ll n,m;cin>>n>>m;
  n %= 2*m;
  if(n<=m){mint ans = modpow(10ll,n,998244353LL);ans--;cout<<ans.val()<<endl;}
  else{mint ans = modpow(10LL,m,998244353LL)-modpow(10LL,n-m,998244353LL);cout << ans.val()<<endl;}
}
int main() {
  int t;cin>>t;
  while(t--){
    solve();
  }
}
0