結果

問題 No.2699 Simple Math (Returned)
ユーザー highlighterhighlighter
提出日時 2024-03-29 21:14:00
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 697 bytes
コンパイル時間 2,872 ms
コンパイル使用メモリ 247,424 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-29 21:14:19
合計ジャッジ時間 12,042 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 610 ms
6,676 KB
testcase_02 AC 731 ms
6,676 KB
testcase_03 AC 613 ms
6,676 KB
testcase_04 WA -
testcase_05 AC 708 ms
6,676 KB
testcase_06 AC 710 ms
6,676 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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