fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m, minus = 1;
  6. cin >> n;
  7. m = 1;
  8. for (int a = 1; n> 0; a *= 10) {
  9. for (int b = a; b < a*10; b++) {
  10. if ((n - minus) < 0) {
  11. cout << 0;
  12. return 0;
  13. }
  14. if ((n - minus) == 0) {
  15. cout << m;
  16. return 0;
  17. }
  18. n-= minus;
  19. m++;
  20. }
  21. minus++;
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 4476KB
stdin
50
stdout
Standard output is empty