1288B - Yet Another Meme Problem - CodeForces Solution


math *1100

Please click on ads to support us..

Python Code:

t = int(input())
for i in range(t):
    a,b = [i for i in input().split()]
    toadd = 0
    cmpr = '9'*len(b)
    if int(b) == int(cmpr):
        toadd = 1
    print(int(a)*(len(b)-1+toadd))

C++ Code:

// Problem: B. Yet Another Meme Problem
// Contest: Codeforces - Educational Codeforces Round 80 (Rated for Div. 2)
// URL: https://codeforces.com/contest/1288/problem/B
// Memory Limit: 256 MB
// Time Limit: 1000 ms

#include<iostream>
#include <bits/stdc++.h>
// #pragma GCC optimize("O3,unroll-loops")
// #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set
using namespace std;
#define fio 	   	   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int        	   long long
#define rep(karu,mera,gaon)     for(int karu=mera;karu<gaon;karu++)
#define vi 		   	   vector<int>
#define pb         	   push_back
#define mii        	   map<int,int>
#define all(x)         (x).begin(),(x).end()
#define endl           '\n' 
#define mem1(a)        memset(a,-1,sizeof(a))
#define mem0(a)        memset(a,0,sizeof(a))
#define pii        	   pair<int,int>
#define pno            cout<<"NO"<<endl
#define pys            cout<<"YES"<<endl
#define fi         	   first
#define se         	   second
#define mp             make_pair
#define setbits(x)     __builtin_popcountll(x)
#define ctz(x)         __builtin_ctzll(x)
#define clz(x)         __builtin_clzll(x)
#define uniq(v)        (v).erase(unique(all(v)),(v).end())
#define sz(x)          (int)((x).size())
#define inf        	   3e18//9223372036854775807//2147483647
#define ld             long double
#define ps(x,y)        fixed<<setprecision(y)<<x
                                
const int mod=1e9+7;//998244353;
const int MAX=1e6;
const long double PI=3.14159265359;
const long double eps=1e-6;                  
//-10
void solve()
{
    fio;
    // int n;cin>>n;
    // vi a(n);
    // rep(i,0,n)
    // cin>>a[i];
    // for(int a=1;a<=100;a++)
    // {
    	// for(int b=1;b<=1000;b++)
    	// {
    		// int l = a + b + a*b;
    		// string R = to_string(a)+to_string(b);
    		// int r = stol(R);
    		// if(l==r)
    		// cout<<a<<' '<<b<<endl;
    	// }
    // }
    int A,B;
    cin>>A>>B;
    int b = 9;
    int ans = 0;
    while(b<=B)
    {
    	ans += A;
    	b = 10 * b + 9;
    }
    cout<<ans<<endl;
    return;
}


int32_t main(){
    fio;
    int t=1;
    cin>>t;
    for(int i=1;i<=t;i++)
    {
    	//cout<<"Case #"<<i<<": ";
    	solve();
    }
    return 0;
}


Comments

Submit
0 Comments
More Questions

1515C - Phoenix and Towers
998A - Balloons
1734F - Zeros and Ones
1144B - Parity Alternated Deletions
92B - Binary Number
1144C - Two Shuffled Sequences
1154B - Make Them Equal
1272B - Snow Walking Robot
522B - Photo to Remember
608B - Hamming Distance Sum
1408F - Two Different
274B - Zero Tree
1726H - Mainak and the Bleeding Polygon
722A - Broken Clock
129B - Students and Shoelaces
697B - Barnicle
903D - Almost Difference
1443B - Saving the City
1215C - Swap Letters
1251C - Minimize The Integer
1494B - Berland Crossword
295A - Greg and Array
1433E - Two Round Dances
1612D - X-Magic Pair
41B - Martian Dollar
906C - Party
774F - Pens And Days Of Week
598B - Queries on a String
1303B - National Project
1303D - Fill The Bag