fork download
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <iomanip>
  4. #include <bits/stdc++.h>
  5. #include <cstdio>
  6. #include <string>
  7. #define ll long long
  8. #define ld long double
  9. #define ST(a) a.first
  10. #define ND(a) a.second
  11. #define fin(a,n) for(int i = a; i < n; i++)
  12. #define fjn(a,n) for(int j = a; j < n; j++)
  13. #define all(a) a.begin(),a.end()
  14. #define FIFO ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
  15.  
  16. using namespace std;
  17.  
  18. ll pre[200005];
  19.  
  20. void solve()
  21. {
  22. ll n; cin >> n;
  23. cout << pre[n] << '\n';
  24. }
  25. int main()
  26. {
  27. FIFO;
  28.  
  29. pre[0] = 0;
  30. for(int i = 1; i < 200005; i++){
  31. pre[i] = pre[i-1];
  32. ll x = i;
  33. while(x){
  34. pre[i] += (x % 10);
  35. x /= 10;
  36. }
  37. }
  38.  
  39. ll tt = 1; cin >> tt;
  40. while(tt--){
  41. solve();
  42. }
  43.  
  44. return 0;
  45. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
0