0
点赞
收藏
分享

微信扫一扫

B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)

原题链接: ​​https://codeforces.com/contest/1288/problems​​

B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_#define
测试样例

Input
3
1 11
4 2
191 31415926
Output
1
0
1337

Note

There is only one suitable pair in the first test case: a=1, b=9 (1+9+1⋅9=19).

题意: 给你一个整数A和B,让你从1~ A中选出一个整数a, 1~B中选出一个整数b,要符合条件B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_自定义_02,其中B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_自定义_03即连接B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_数学_04B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_#define_05。让你求出有多少组这样的组合。

解题思路: 一道妥妥的数学+思维问题。由于连接B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_数学_04B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_思维_07是不属于数学的表达,我们可以设B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_思维_07的位数为num。那么B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_ios_09即可表示为B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_ios_10,我们将此式代回原式可得B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_#define_11 我们发现要使得这个式子满足的条件只关心B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_思维_07的值,B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_数学_04取什么都行。我们再观察B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_数学_14只可能是10、100···,那么转换之后也就是说我们要判断位数上都是9的数字有多少个。之后与B. Yet Another Meme Problem(数学+思维)Educational Codeforces Round 80 (Rated for Div. 2)_数学_04的范围相乘即可。OK,具体看代码。

AC代码

/*

*
*/
#include<bits/stdc++.h> //POJ不支持

#define rep(i,a,n) for (int i=a;i<=n;i++)//i为循环变量,a为初始值,n为界限值,递增
#define per(i,a,n) for (int i=a;i>=n;i--)//i为循环变量, a为初始值,n为界限值,递减。
#define pb push_back
#define IOS ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define mp make_pair

using namespace std;

const int inf = 0x3f3f3f3f;//无穷大
const int maxn = 1e5;//最大值。
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
//*******************************分割线,以上为自定义代码模板***************************************//

ll t,a,b;
void solve(){
ll cnt=0,temp=9;
while(b>=temp){
temp=temp*10+9;
cnt++;
}
//得到位数都是9的数量。
cout<<a*cnt<<endl;
}
int main(){
//freopen("in.txt", "r", stdin);//提交的时候要注释掉
IOS;
while(cin>>t){
while(t--){
cin>>a>>b;
solve();
}
}
return 0;
}


举报

相关推荐

0 条评论