fork download
  1. /*
  2. Solution By - Amrutansu Garanaik
  3. Codechef ID - dragonemperor
  4. */
  5.  
  6. #include<stdio.h>
  7. #include<math.h>
  8. #define MAX 1000000
  9. long long ans[MAX];
  10. void preprocess()
  11. {
  12. long double var=0,temp;
  13. ans[0]=1;
  14. for(int i=1;i<MAX;i++)
  15. {
  16. temp=log(i)/log(10);
  17. var+=temp;
  18. ans[i]=(long long)var+1;
  19. }
  20. }
  21. int main()
  22. {
  23. preprocess();
  24. long long test,n;
  25. scanf("%lld",&test);
  26. while(test--)
  27. {
  28. scanf("%lld",&n);
  29. printf("%lld\n",ans[n]);
  30. }
  31. return 0;
  32. }
Success #stdin #stdout 0.12s 10504KB
stdin
2
5
9
stdout
3
6