fork download
  1. #include <bits/stdc++.h>
  2. #define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  3. #define pb push_back
  4. #define show(x) cout<<(#x)<<" : "<<x<<endl;
  5. #define ll long long
  6. #define ld long double
  7. #define fill(a,val) memset(a,val,sizeof(a))
  8. #define mp make_pair
  9. #define ff first
  10. #define ss second
  11. #define pii pair<ll,ll>
  12. #define sq(x) ((x)*(x))
  13. #define all(v) v.begin(),v.end()
  14. #define rall(v) v.rbegin(),v.rend()
  15. const ll INF = 1ll*1000*1000*1000*1000*1000*1000 + 7;
  16. using namespace std;
  17.  
  18. ll power(ll x, ll y)
  19. {
  20. if (y == 0)
  21. return 1;
  22. else if (y % 2 == 0)
  23. return power(x, y / 2) * power(x, y / 2);
  24. else
  25. return x * power(x, y / 2) * power(x, y / 2);
  26. }
  27.  
  28.  
  29. int main()
  30. {
  31. int T;
  32. cin>>T;
  33. while(T--)
  34. {
  35.  
  36. ll A;
  37. string B;
  38. cin>>A>>B;
  39.  
  40. ll X=B.length();
  41. ll P=stoi(B);
  42.  
  43. if (P==(power(10, X)-1))
  44. X=B.length();
  45. else
  46. X=B.length()-1;
  47.  
  48. ll C=A*X;
  49.  
  50.  
  51. cout<<C<<'\n';
  52.  
  53. }
  54. return 0;
  55. }
Success #stdin #stdout 0s 4308KB
stdin
3
1 11
4 99
191 31415926
stdout
1
8
1337