fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4.  
  5. int main() {
  6. ll ttt; cin >> ttt;
  7. for (ll k = 1; k <= ttt; k++)
  8. {
  9. string n; cin >> n;
  10. vector < string > a;
  11. char ab[10] = {'1', '2', '3', '4', '5', '6', '7', '8', '9'};
  12. for (ll i = 0; i < 10; i++)
  13. {
  14. for (ll j = 1; j <= 4; j++)
  15. {
  16. string s = "";
  17.  
  18. for (ll k = 1; k <= j; k++)
  19. {
  20. s += ab[i];
  21. }
  22. a.push_back(s);
  23. }
  24. }
  25. ll t = 0;
  26. cout << n << endl;
  27. for (ll i = 0; i < 36; i++)
  28. {
  29. t += a[i].size();
  30. if (a[i] == n)
  31. {
  32. cout << t;
  33. return 0;
  34. }
  35.  
  36.  
  37. }
  38. }
  39. }
  40.  
Success #stdin #stdout 0s 5320KB
stdin
5
3
44
222
9999
7
stdout
3
21