# Educational Codeforces Round 80 (Rated for Div. 2)B. Yet Another Meme Problem

## B. Yet Another Meme Problem

• 代码1
用一个数组存取9种可能再与B值相比较即可
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=0x3f3f3f;
int s[15];
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);

int t,c=1;
cin>>t;
for(int i=0;i<9;i++){
c*=10;
s[i]=c-1;
}
while(t--){
ll a,b;
cin>>a>>b;
int i;
for(i=0;i<9;i++){
if(b<s[i])
break;
}
if(b<s[i]||i==9) b=i;
else b=i+1;
ll ans=a*b;
cout<<ans<<endl;
}
return 0;
}

• 代码2
更加暴力
除了代码比较长没什么毛病，更容易理解
~
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int INF=0x3f3f3f;
int main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);

int t;
cin>>t;
while(t--){
ll a,b;
cin>>a>>b;
if(b<9)
cout<<"0"<<endl;
else{
if(b<99)
cout<<a<<endl;
else if(b<999)
cout<<a*2<<endl;
else if(b<9999)
cout<<a*3<<endl;
else if(b<99999)
cout<<a*4<<endl;
else if(b<999999)
cout<<a*5<<endl;
else if(b<9999999)
cout<<a*6<<endl;
else if(b<99999999)
cout<<a*7<<endl;
else if(b<999999999)
cout<<a*8<<endl;
else
cout<<a*9<<endl;
}
}
return 0;
}


©️2019 CSDN 皮肤主题: 1024 设计师: 上身试试