fork download
  1. #include<iostream>
  2. #include<math.h>
  3. #include<stdio.h>
  4. using namespace std;
  5. int main()
  6. {
  7. int xy,z;
  8. long long int persons,min_pow,part,ans;
  9. scanf("%de%d",&xy,&z);
  10. while(!(xy==0 && z==0))
  11. {
  12. persons=xy;
  13. while(z!=0)
  14. {
  15. persons=persons*10;
  16. z--;
  17. }
  18. min_pow=log(persons)/log(2);
  19. part=persons-pow(2,min_pow);
  20. ans=(part*2)+1;
  21. printf("\n%lld",ans);
  22. scanf("%de%d",&xy,&z);
  23. }
  24.  
  25. return 0;
  26.  
  27. }
  28.  
  29.  
Success #stdin #stdout 0s 3344KB
stdin
05e0
01e1
42e0
66e6
00e0
stdout
3
5
21
64891137