結果
| 問題 |
No.2699 Simple Math (Returned)
|
| コンテスト | |
| ユーザー |
inkyaman
|
| 提出日時 | 2024-03-29 21:43:43 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,343 bytes |
| コンパイル時間 | 1,244 ms |
| コンパイル使用メモリ | 112,540 KB |
| 最終ジャッジ日時 | 2025-02-20 14:53:05 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 2 WA * 9 |
ソースコード
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;
int T;
ll mod = 998244353;
//ループの回数は適宜修正
ll power(ll a, ll b, ll m) {
ll p = a, ans = 1;
for(int i = 0; i < 60; i++) {
ll wari = (1LL << i);
if((b / wari) % 2 == 1) {
ans = (ans * p) % m;
}
p = (p * p) % m;
}
return ans;
}
ll division(ll a, ll b, ll m) {
return ((a % m) * power(b, m-2, m)) % m;
}
int main() {
cin >> T;
while(T--) {
ll N, M;
cin >> N >> M;
if(N <= M) {
cout << power(10,N,mod) << endl;
} else {
ll r = N%(2*M);
ll ans;
if(r < M) {
ans = power(10,r,mod);
ans = (ans-1+mod)%mod;
} else {
ll a = power(10,M,mod);
a = (a-1+mod)%mod;
ll b = power(10,r-M,mod);
b = (b-1+mod)%mod;
ans = (a-b+mod)%mod;
}
cout << ans << endl;
}
}
}
inkyaman