結果

問題 No.2699 Simple Math (Returned)
ユーザー 👑 chro_96chro_96
提出日時 2024-03-29 22:09:06
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 345 ms / 2,000 ms
コード長 811 bytes
コンパイル時間 1,227 ms
コンパイル使用メモリ 31,036 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-29 22:09:12
合計ジャッジ時間 5,767 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,676 KB
testcase_01 AC 66 ms
6,676 KB
testcase_02 AC 247 ms
6,676 KB
testcase_03 AC 65 ms
6,676 KB
testcase_04 AC 345 ms
6,676 KB
testcase_05 AC 213 ms
6,676 KB
testcase_06 AC 153 ms
6,676 KB
testcase_07 AC 294 ms
6,676 KB
testcase_08 AC 291 ms
6,676 KB
testcase_09 AC 300 ms
6,676 KB
testcase_10 AC 293 ms
6,676 KB
testcase_11 AC 291 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0