假设字符串长度为,字符串长度为 其实观察我们可以发现对于字符串中的每位都加了次,对于字符串的每位都加了次,然后注意每一位的值不是单一数字是需要*当前位的权值即可。 小tips:最好用快速幂写,pow有可能不靠谱。
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
# include<bits/stdc++.h>
# include<unordered_map>
# define eps 1e-9
# define fi first
# define se second
# define ll long long
# define int ll
# define x1 sb
# define y1 dsb
# define x2 ssb
# define y2 ddsb
// cout<<fixed<<setprecision(n)
//bool operator<(const Node& x )
using namespace std;
typedef unsigned long long ull;
typedef pair<int,int > PII;
const int mod=998244353;
const int N=2e6+10;
const int Time=86400;
const int X=131;
const int inf=0x3f3f3f3f;
const double PI = 1e-4;
double pai = 3.14159265358979323846;
double e = exp(1);
int T,n,q,m,k,ans,res,sum,x1,y1,x2,y2;
map<int,int>mp;
string a,b;
int qsm(int a,int b){
int res = 1;
while(b){
if(b&1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res % mod;
}
void solve(){
ans = 0;
cin >> a >> b;
n = a.size();m = b.size();
for(int i = 0 ; i < n ; i ++ ){
int x = a[i]-'0';
x = x * qsm(10,n-i-1) % mod;
ans = (ans + x*m%mod) % mod;
}
for(int i = 0 ; i < m ; i ++ ){
int x = b[i]-'0';
x = x * qsm(10,m-i-1) % mod;
ans = (ans + x*n%mod) % mod;
}
cout<<ans<<"\n";
}
/*
2 9 6 7 10
2 6 7 9 10
*/
signed main(){
std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
cin >> T;
//T = 1;
while(T--){
solve();
}
return 0;
}