T2

题意实际上就是求 bb 的每一位与 aa 的乘积之和。

按题意模拟即可。

时间复杂度 O(n)O(n)

//Man always remember love because of romance only!
#include<bits/stdc++.h>
using namespace std;
#define int long long
inline int read(){
    int X=0,w=0; char ch=0;
    while(!isdigit(ch)) {w|=ch=='-';ch=getchar();}
    while(isdigit(ch)) X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
    return w?-X:X;
}
inline void write(int x){
	if(x<0) putchar('-'),x=-x;
    if(x>9) write(x/10);
    putchar(x%10+'0');
}
signed main(){
	int T=read();
	while(T--){
		int a=read(),b=read();
		int ans=0;
		while(b){
			ans+=(b%10)*a;
			b/=10;
		}
		write(ans);
		puts("");
	}
	return 0;
}