Advertisement
newb_ie

Untitled

Oct 5th, 2021
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. vector<string> comb;
  5.  
  6. void rec (int n,int i,string s) {
  7. if (i == n) {
  8. comb.push_back(s);
  9. return;
  10. }
  11. rec(n,i + 1,s + '0');
  12. rec(n,i + 1,s + '1');
  13. }
  14.  
  15. int main () {
  16. ios::sync_with_stdio(false);
  17. cin.tie(nullptr);
  18. cout.tie(nullptr);
  19. for (int i = 1; i <= 10; ++i) {
  20. rec(i,0,"");
  21. }
  22. vector<long long> a;
  23. for (string s : comb) {
  24. //1 => 7
  25. //0 => 4
  26. //~ 101 => 747
  27. long long x = 0;
  28. for (int i = 0; i < (int) s.size(); ++i) {
  29. if (s[i] == '1') {
  30. x = x * 10 + 7;
  31. } else {
  32. x = x * 10 + 4;
  33. }
  34. }
  35. a.push_back(x);
  36. }
  37. sort (a.begin(),a.end());
  38. //~ for (int i = 0; i < 10; ++i) {
  39. //~ cout << a[i] << ' ';
  40. //~ }
  41. int n;
  42. cin >> n;
  43. for (int i = 0; i < (int) a.size(); ++i) {
  44. if (a[i] == n) {
  45. cout << i + 1 << '\n';
  46. return 0;
  47. }
  48. }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement