fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. ll pow2(int a)
  6. {
  7. if(a)return 1<<a;
  8. return 1;
  9. }
  10. ll pow3(int a)
  11. {
  12. if(a)return 1<<a;
  13. return 0;
  14. }
  15. ll f(string x)
  16. {
  17. ll j;
  18. if(x=="0")return 1;
  19. if(x=="1")return 2;
  20. if(x[0]=='0')j=(1<<((int)x.length()))-2;
  21. else j=(1<<((int)x.length()-1))+(1<<((int)x.length()))-2;
  22. j++;
  23. reverse(x.begin(),x.end());
  24. int l=x.length()-1;
  25. for(int i=0;i<l;i++)
  26. if(x[i]=='1')j+=pow2(i);
  27. return j;
  28. }
  29.  
  30.  
  31. int main()
  32. {
  33. char ch;
  34. string s="";
  35. while(cin>>ch)ch=='4' ? s+='0' : s+='1';
  36. cout<<f(s);
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 3280KB
stdin
77
stdout
6