int类型最多表示的21亿,这个题int就可以。
#include <bits/stdc++.h>
using namespace std;
int getSum(int a){
int res = 0;
while(a){
res += a%10;
a/=10;
}
return res;
}
int main(){
int n;
cin>>n;
while(n--){
int a,b;
cin>>a>>b;
int s1=getSum(a);
int s2=getSum(b);
if(a%s2==0&&b%s1==0){//都满足
cout << (a > b ? "A":"B") << '\n';
}else if(a%s2==0){
cout << "A" << '\n';
}else if(b%s1==0){
cout << "B" << '\n';
}else{
cout << (a > b ? "A":"B") << '\n';
}
}
return 0;
}
标签:a%,int,res,s1,096,getSum,L1
From: https://www.cnblogs.com/chengyiyuki/p/18110022