Saleh127

Untitled

May 11th, 2020
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int t,a,c,d,e,f,i,j,k,l;
  6. cin>>t;
  7. while(t--)
  8. {
  9. cin>>a;
  10. if(a<=9) printf("%d\n",a);
  11. else
  12. {
  13. c=0;
  14. for(i=1;i<=a;i=i*10+1)
  15. {
  16. c+=min(9,(a/i));
  17. }
  18. cout<<c<<endl;
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment