-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTavas_and_SaDDas.cpp
101 lines (77 loc) · 1.62 KB
/
Tavas_and_SaDDas.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
///link of problem : https://codeforces.com/contest/535/problem/B
#include<bits/stdc++.h>
#include<iostream> ///* code by Ahmed Elnemr *///
using namespace std;
///template<typename type1,typename type2>
///#define b 10 --> const int b= 10;
#define ll long long
#define f first
#define sec second
#define endl "\n"
#define lp(n) for(ll i=0;i<n;i++)
#define lp2(n) for(ll j=0;j<n;j++)
#define sp(n) fixed<<setprecision(n)
#define ist set<int>
#define llset set<ll>
#define ivec vector<int>
#define llvec vector<ll>
void fast_run()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
//vector<string> arr ;
llvec arr;
ll make_num (string s) {
ll l=s.size();
string x=s;
lp(l) {
if(s[i]=='1')
x[i]='7';
else
x[i]='4';
}
return stoi(x);
}
signed main() {
fast_run();
int t=1;
//cin>>t;
while(t--) {
string n,s;
cin>>n;
lp(n.size()) {
s+="0";
}
ll cnt=0,l=n.size();
for(ll i=1;i<=l-1;i++) {
cnt+= pow(2,i);
}
lp((1<<n.size())) {
int msk=i,j=0; string ss=s;
while(msk) {
if(msk&1) {
ss[j]='1';
}
msk=msk>>1;
j++;
}
arr.push_back(make_num(ss));
}
sort(arr.begin(),arr.end());
ll nn = stoll(n);
lp(arr.size()) {
if(arr[i]==nn) {
cnt++;
break;
}
else {
cnt++;
}
}
cout<<cnt<<endl;
//lp(arr.size()) {cout<<arr[i]<<" ";}
}
return 0;
}