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;
}

 

發佈了74 篇原創文章 · 獲贊 26 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章