結果
| 問題 |
No.2699 Simple Math (Returned)
|
| コンテスト | |
| ユーザー |
highlighter
|
| 提出日時 | 2024-03-29 21:09:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 826 bytes |
| コンパイル時間 | 3,052 ms |
| コンパイル使用メモリ | 246,852 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-09-30 15:29:00 |
| 合計ジャッジ時間 | 10,944 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 5 WA * 6 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
int power(int a,int b,int mod){
vector<int> vec(62);
vec[0]=a%mod;
for(int i=1;i<62;i++){
vec[i]=vec[i-1]*vec[i-1]%mod;
}
bitset<62> x(b);
int ans=1;
for(int i=0;i<62;i++){
if(x[i]==1){
ans*=vec[i];
ans%=mod;
}
}
return ans;
}
const int mod=998244353;
signed main(){
int T;
cin >> T;
for(;T--;){
int N,M;
cin >> N >> M;
if(N<=M){
int ans=power(10,N,mod)-1;
ans%=mod;
if(ans<0){
ans+=mod;
}
cout << ans << endl;
continue;
}
int t=N%(2*M);
if(t<=M){
int ans=power(10,t,mod)-1;
ans%=mod;
if(ans<0){
ans+=mod;
}
cout << ans << endl;
continue;
}
if(t>M){
int ans=power(10,t-M,mod)+1;
ans*=-1;
ans%=mod;
if(ans<0){
ans+=mod;
}
cout << ans << endl;
}
}
}
highlighter