結果
| 問題 | 
                            No.2699 Simple Math (Returned)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             chro_96
                         | 
                    
| 提出日時 | 2024-03-29 22:09:06 | 
| 言語 | C  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 304 ms / 2,000 ms | 
| コード長 | 811 bytes | 
| コンパイル時間 | 484 ms | 
| コンパイル使用メモリ | 31,536 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-09-30 16:04:05 | 
| 合計ジャッジ時間 | 4,329 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 11 | 
ソースコード
#include <stdio.h>
long long power_mod (long long a, long long b, long long mod_num) {
  long long ans = 1LL;
  
  if (b > 0LL) {
    ans = power_mod(a, b/2LL, mod_num);
    ans = (ans * ans) % mod_num;
    if (b%2LL == 1LL) {
      ans = (ans * (a % mod_num)) % mod_num;
    }
  }
  
  return ans;
}
int main () {
  int t = 0;
  long long n = 0LL;
  long long m = 0LL;
  
  int res = 0;
  
  long long mod_num = 998244353LL;
  
  res = scanf("%d", &t);
  while (t > 0) {
    res = scanf("%lld", &n);
    res = scanf("%lld", &m);
    n %= 2LL*m;
    if (n > m) {
      printf("%lld\n", (((power_mod(10LL, 2LL*m-n, mod_num)+mod_num-1LL)%mod_num)*power_mod(10LL, n-m, mod_num))%mod_num);
    } else {
      printf("%lld\n", (mod_num-1LL+power_mod(10LL, n, mod_num))%mod_num);
    }
    t--;
  }
  
  return 0;
}
            
            
            
        
            
chro_96