結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 363 ms
6,676 KB
testcase_02 AC 462 ms
6,676 KB
testcase_03 AC 364 ms
6,676 KB
testcase_04 AC 482 ms
6,676 KB
testcase_05 AC 438 ms
6,676 KB
testcase_06 AC 420 ms
6,676 KB
testcase_07 AC 465 ms
6,676 KB
testcase_08 AC 467 ms
6,676 KB
testcase_09 AC 471 ms
6,676 KB
testcase_10 AC 488 ms
6,676 KB
testcase_11 AC 461 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(){
  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