fork download
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5. int n, nn, sum, one, count;
  6.  
  7. for (count = sum = n = 0; n < 0x7FFFffff; n++) {
  8. // nに含まれる1の個数を求める
  9. nn = n;
  10. for (one = 0; nn > 0; nn /= 10) {
  11. if (nn % 10 == 1) {
  12. one++;
  13. }
  14. }
  15. // 累計
  16. sum += one;
  17. if (n > 0 && n == sum) {
  18. count++;
  19. if (count == 2) {
  20. printf("%d\n", n);
  21. return 0;
  22. }
  23. }
  24. }
  25. printf("0-%dの間では見つからなかった\n", 0x7FFFffff);
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 1788KB
stdin
Standard input is empty
stdout
199981