Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- vector<string> comb;
- void rec (int n,int i,string s) {
- if (i == n) {
- comb.push_back(s);
- return;
- }
- rec(n,i + 1,s + '0');
- rec(n,i + 1,s + '1');
- }
- int main () {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- for (int i = 1; i <= 10; ++i) {
- rec(i,0,"");
- }
- vector<long long> a;
- for (string s : comb) {
- //1 => 7
- //0 => 4
- //~ 101 => 747
- long long x = 0;
- for (int i = 0; i < (int) s.size(); ++i) {
- if (s[i] == '1') {
- x = x * 10 + 7;
- } else {
- x = x * 10 + 4;
- }
- }
- a.push_back(x);
- }
- sort (a.begin(),a.end());
- //~ for (int i = 0; i < 10; ++i) {
- //~ cout << a[i] << ' ';
- //~ }
- int n;
- cin >> n;
- for (int i = 0; i < (int) a.size(); ++i) {
- if (a[i] == n) {
- cout << i + 1 << '\n';
- return 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement