Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- //using namespace chrono;
- typedef long long ll;
- typedef vector< int > vi;
- typedef vector< ll > V;
- typedef map<int, int > mp;
- #define pb push_back
- #define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
- #define F first
- #define S second
- #define debug cout << -1 << endl;
- #define REP(i, a, b) for(int i=a; i<b; i++)
- #define f0r(i, n) for (int i = 0; i < n; ++i)
- #define f0r1(i, n) for (int i = 1; i <= n; ++i)
- #define r0f(i, n) for(int i=n-1; i>=0; i--)
- #define r0f1(i, n) for(int i=n; i>=1; i--)
- #define fore(a, x) for (auto& a : x)
- #define fori(i, a, b) for (int i = (a); i < (b); ++i)
- #define MP make_pair
- #define UB upper_bound
- #define LB lower_bound
- #define nw cout << "\n"
- #define issq(x) (((ll)(sqrt((x))))*((ll)(sqrt((x))))==(x))
- #define rev(v) reverse(v.begin(),v.end())
- #define asche cerr<<"Ekhane asche\n";
- #define rev(v) reverse(v.begin(),v.end())
- #define srt(v) sort(v.begin(),v.end())
- #define grtsrt(v) sort(v.begin(),v.end(),greater<ll>())
- #define all(v) v.begin(),v.end()
- #define mnv(v) *min_element(v.begin(),v.end())
- #define mxv(v) *max_element(v.begin(),v.end())
- #define valid(tx,ty) (tx>=0 && tx<n && ty>=0 && ty<m)
- #define one(x) __builtin_popcount(x)
- //#define pop pop_back
- #define setPrec(x) cout << fixed << setprecision(x)
- #define sz(a) (int)a.size()
- //#define fin cin
- //#define fout cout
- const int INF = 1e9;
- const ll MOD = (ll)1e9+7;
- const ll INFL = 1e18;
- const ll mnINF = -1e18;
- const double diff = 10e-6;
- const int maxn = 500005;
- const double PI = acos(-1);
- using namespace std;
- // int dx[] = {-1, 0, 1};
- // int dy[] = {-1, 0, 1};
- int dx[] = {-1, 0, 0, 1};
- int dy[] = {0, -1, 1, 0};
- vector< ll > v;
- int arr[] = {4, 7};
- void gen2()
- {
- ll x = 0LL;
- f0r(i, 2) f0r(j, 2) {
- x = arr[i]*10 + arr[j];
- v.pb(x);
- }
- }
- void gen3()
- {
- ll x = 0LL;
- f0r(i, 2) f0r(j, 2) f0r(k, 2) {
- x = arr[i]*100 + arr[j]*10 + arr[k];
- v.pb(x);
- }
- }
- void gen4()
- {
- ll x = 0LL;
- f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) {
- x = arr[i]*100 + arr[j]*10 + arr[k];
- x*=10LL;
- x += arr[l];
- v.pb(x);
- }
- }
- void gen5()
- {
- ll x = 0LL;
- f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2){
- x = arr[i]*100 + arr[j]*10 + arr[k];
- x*=10LL;
- x += arr[l];
- x *= 10LL;
- x += arr[m];
- v.pb(x);
- }
- }
- void gen6()
- {
- ll x = 0LL;
- f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2) f0r(o, 2){
- x = arr[i]*100 + arr[j]*10 + arr[k];
- x*=10LL;
- x += arr[l];
- x *= 10LL;
- x += arr[m];
- x *= 10LL;
- x += arr[o];
- v.pb(x);
- }
- }
- void gen7()
- {
- ll x = 0LL;
- f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2) f0r(o, 2) f0r(p, 2){
- x = arr[i]*100 + arr[j]*10 + arr[k];
- x*=10LL;
- x += arr[l];
- x *= 10LL;
- x += arr[m];
- x *= 10LL;
- x += arr[o];
- x *= 10LL;
- x += arr[p];
- v.pb(x);
- }
- }
- void gen8()
- {
- ll x = 0LL;
- f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2) f0r(o, 2) f0r(p, 2) f0r(q, 2){
- x = arr[i]*100 + arr[j]*10 + arr[k];
- x*=10LL;
- x += arr[l];
- x *= 10LL;
- x += arr[m];
- x *= 10LL;
- x += arr[o];
- x *= 10LL;
- x += arr[p];
- x *= 10LL;
- x += arr[q];
- v.pb(x);
- }
- }
- void gen9()
- {
- ll x = 0LL;
- f0r(i, 2) f0r(j, 2) f0r(k, 2) f0r(l, 2) f0r(m, 2) f0r(o, 2) f0r(p, 2) f0r(q, 2) f0r(r, 2){
- x = arr[i]*100 + arr[j]*10 + arr[k];
- x*=10LL;
- x += arr[l];
- x *= 10LL;
- x += arr[m];
- x *= 10LL;
- x += arr[o];
- x *= 10LL;
- x += arr[p];
- x *= 10LL;
- x += arr[q];
- x *= 10LL;
- x += arr[r];
- v.pb(x);
- }
- }
- void solve()
- {
- v.pb(4);
- v.pb(7);
- gen2(); gen3(); gen4(); gen5(); gen6(); gen7(); gen8();
- gen9();
- // for(auto xx: v) cout << xx << "\n";
- ll x;
- cin >> x;
- cout << upper_bound(v.begin(), v.end(), x)-v.begin() << "\n";
- }
- void setIO(string name = "") { // name is nonempty for USACO file I/O
- ios_base::sync_with_stdio(0); cin.tie(0); // see Fast Input & Output
- // alternatively, cin.tie(0)->sync_with_stdio(0);
- if (name.size()) {
- freopen((name+".in").c_str(), "r", stdin); // see Input & Output
- freopen((name+".out").c_str(), "w", stdout);
- }
- }
- int main()
- {
- //setIO("breedflip");
- FastIO;
- int t;
- t = 1;
- // cin >> t;
- f0r(i, t) {
- //cout << "Case " << i+1 << ": ";
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement