結果
| 問題 | 
                            No.2699 Simple Math (Returned)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Magentor
                         | 
                    
| 提出日時 | 2023-12-08 21:10:37 | 
| 言語 | C++23  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 508 ms / 2,000 ms | 
| コード長 | 644 bytes | 
| コンパイル時間 | 5,561 ms | 
| コンパイル使用メモリ | 307,544 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-27 03:38:22 | 
| 合計ジャッジ時間 | 12,067 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 11 | 
ソースコード
#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();
  }
}
            
            
            
        
            
Magentor