fork download
  1. #include <iostream>
  2. #include<cstdio>
  3. #include<string>
  4. #include<vector>
  5. int const n= 100;
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. string s;
  11. int x,z,n=1,i=0,flag;
  12. cin>>s;
  13. vector<int> v;
  14. v.push_back(n);
  15. while(n<=99000001)
  16. {
  17.  
  18. n=n*2;
  19. v.push_back(n);
  20. }
  21. while(s[0]!='0' || s[1]!='0')
  22. {
  23. //cout<<s<<endl;
  24. x=10*(s[0]-48)+(s[1]-48);
  25. z=s[3]-48;
  26. while(z--)
  27. x=x*10;
  28. //cout<<x<<endl;
  29. flag=0;
  30. for(int i=0;i<v.size();i++)
  31. {
  32. if(x==v[i])
  33. {printf("1\n");
  34. flag=1;
  35. break;
  36. }
  37. else if(x>v[i]&& x<v[i+1])
  38. {
  39. x=x-v[i];
  40. break;
  41. }
  42. else
  43. continue;
  44. }
  45. if(flag!=1)
  46. { x= 3+(x-1)*2;
  47.  
  48. printf("%d\n",x);
  49. }
  50. cin>>s;
  51.  
  52. }
  53.  
  54.  
  55.  
  56. return 0;
  57. }
Success #stdin #stdout 0s 3432KB
stdin
05e0
01e1
42e0
66e6
00e0
stdout
3
5
21
64891137