【Codeforces Round #299 (Div. 2) B】Tavas and SaDDas
【链接】 我是链接,点我呀:)
【题意】
【题解】
每次取出最小的数字,在后面加上一个4或一个7就好; 会发现最后的数字很少的。【代码】
#include <bits/stdc++.h>
using namespace std;
#define ll long long
priority_queue <ll,vector <ll>,greater <ll> > dl;
vector <ll> v;
int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "rt", stdin);
#endif
dl.push(4);
dl.push(7);
ll x = dl.top();
while (x <= (int) 1e9){
v.push_back(x);
dl.pop();
ll temp = x*10 + 4;
dl.push(temp);
temp = x*10+7;
dl.push(temp);
x = dl.top();
}
while (!dl.empty()){
v.push_back(dl.top());
dl.pop();
}
scanf("%lld",&x);
for (int i = 0;i < (int) v.size();i++)
if (v[i]==x){
printf("%d\n",i+1);
return 0;
}
return 0;
}