CF Yet Another Meme Problem(预处理+找规律)

题意比较简单,做这种题目,应该得有一种条件反射,绝对不可能暴力,数据这么大,要么预处理要么找规律!

规律我是憨憨了没看出来看看这位大佬的https://blog.csdn.net/mrcrack/article/details/103982862

我的代码写得还算好看哈哈哈哈哈

#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <cmath>
#include <sstream>
using namespace std;
typedef long long ll;
int main()
{
    int t = 1;
    ll sum[11];
    sum[0] = 0;
    for (int i = 1; i <= 9; i++)
    {
        t = t * 10;
        sum[i] = t - 1;
    }
    int T;
    cin >> T;
    while (T--)
    {
        ll a, b, i;
        int cnt;
        cin >> a >> b;
        int p = lower_bound(sum, sum + 10, b) - sum;
        if (b == sum[p])
            cnt = p;
        else
            cnt = p - 1;
        cout << a * cnt << endl;
    }
    return 0;
}
发布了51 篇原创文章 · 获赞 21 · 访问量 3068

猜你喜欢

转载自blog.csdn.net/qq_44115065/article/details/103984996