結果

問題 No.2699 Simple Math (Returned)
ユーザー Magentor
提出日時 2025-02-25 12:18:55
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 737 bytes
コンパイル時間 3,425 ms
コンパイル使用メモリ 272,752 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-25 12:19:02
合計ジャッジ時間 6,932 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 2 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 998244353;

ll modpow(ll base, ll exp, ll mod) {
    ll res = 1;
    while (exp > 0) {
        if (exp % 2 == 1) res = res * base % mod;
        base = base * base % mod;
        exp /= 2;
    }
    return res;
}

void solve() {
    ll N, M;
    cin >> N >> M;
    ll mod_val = 10 * modpow(10, M, MOD) + 1;
    ll r = N % (2 * M);
    
    if (r == 0) {
        cout << 0 << '\n';
        return;
    }
    
    ll result = (modpow(10, r, mod_val) - 1 + mod_val) % mod_val;
    cout << result % MOD << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int T;
    cin >> T;
    while (T--) {
        solve();
    }
}

0