fork download
  1. #include <inttypes.h>
  2. #include <stdio.h>
  3.  
  4. int main(void)
  5. {
  6. uintmax_t n = 0;
  7. for (int b; (b = getchar()) != EOF; ) {
  8. if (b == '1')
  9. n = 2*n + 1;
  10. else if (b == '0')
  11. n *= 2;
  12. else // end of the number
  13. break;
  14. }
  15. return printf("%" PRIuMAX "\n", n) < 0;
  16. }
Success #stdin #stdout 0s 9432KB
stdin
001100111000
stdout
824