結果

問題 No.2699 Simple Math (Returned)
ユーザー airthsairths
提出日時 2024-03-29 23:32:08
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,635 bytes
コンパイル時間 1,517 ms
コンパイル使用メモリ 131,228 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-29 23:32:12
合計ジャッジ時間 3,960 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

/*
 * 
 * 	^v^
 * 
 */
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <iomanip>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <climits>
#include <cstdlib>
#include <chrono>
using namespace std;
#define iamtefu ios_base::sync_with_stdio(false); cin.tie(0);
#define ll long long int
#define ld long double
#define fl(i,a,n) for (ll i(a); i<n; i++)
#define rfl(i,a,n) for (ll i(n-1); i>=a; i--)
#define print(a) for (auto x:a){cout<<x<<" ";} cout<<"\n";
#define tt int tt; cin>>tt; for(;tt--;)
template <typename T1, typename T2>
decltype(auto) max(T1 a, T2 b){return (a>b?a:b);}
template <typename T1, typename T2>
decltype(auto) min(T1 a, T2 b){return (a<b?a:b);}
ll gcd(ll a, ll b){
	if (b==0){
		return a;
	}
	return gcd(b, a%b);
}
ll pw(ll a, ll b, ll m){
	ll res=1;
	a%=m;
	while (b){
		if (b&1){
			res=(res*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return res;
}

const ll mod = 998244353;

void scn(){
	ll n, m; cin>>n>>m;
	if (n<=m){
		cout<<(pw(10, n, mod)-1+mod)%mod<<'\n';
	} else {
		n%=(2*m);
		if (n>m){
			cout<<(((pw(10, n, mod)-1+mod)%mod)*(pw(10, (n-m)%m, mod)))%mod<<'\n';
		} else {
			cout<<((pw(10, n, mod)-1+mod)%mod)%mod<<'\n';
		}
	}
}
int main(){
	iamtefu;
	#if defined(airths)
		auto t1=chrono::high_resolution_clock::now();
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	tt
	{
		scn();
	}
	#if defined(airths)
		auto t2=chrono::high_resolution_clock::now();
		ld ti=chrono::duration_cast<chrono::nanoseconds>(t2-t1).count();
		ti*=1e-6;
		cerr<<"Time: "<<setprecision(9)<<ti;
		cerr<<"ms\n";
	#endif
	return 0;
}
0