結果

問題 No.2699 Simple Math (Returned)
ユーザー ochiaigawaochiaigawa
提出日時 2024-03-29 21:12:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 134 ms / 2,000 ms
コード長 682 bytes
コンパイル時間 2,475 ms
コンパイル使用メモリ 204,896 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-29 21:13:01
合計ジャッジ時間 5,032 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,676 KB
testcase_01 AC 51 ms
6,676 KB
testcase_02 AC 96 ms
6,676 KB
testcase_03 AC 47 ms
6,676 KB
testcase_04 AC 134 ms
6,676 KB
testcase_05 AC 88 ms
6,676 KB
testcase_06 AC 77 ms
6,676 KB
testcase_07 AC 115 ms
6,676 KB
testcase_08 AC 115 ms
6,676 KB
testcase_09 AC 117 ms
6,676 KB
testcase_10 AC 116 ms
6,676 KB
testcase_11 AC 115 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using mint = atcoder::modint998244353;
int main() {
  cin.tie(0); cout.tie(0);
  ios::sync_with_stdio(false);
  int T;
  cin >> T;
  while(T--) {
    int N, M;
    cin >> N >> M;
    if(N % (M * 2) == 0) {
      cout << 0 << '\n';
    } else {
      mint X = mint(10).pow(N % (M * 2)) - 1;
      int keta = N % (M * 2);
      if(keta <= M) {
        cout << X.val() << '\n';
      } else {
        mint Y = mint(10).pow(M) + 1;
        X -= Y * mint(mint(10).pow(keta - M) - 1);
        cout << X.val() << '\n';
      }
    }
  }
  return 0;
}
0