原题:http://codeforces.com/problemset/problem/535/B
题意:求1 ~ n中只包含4、7的数有多少个;
#include<stdio.h>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;
struct node
{
long long x;
};
queue<node>q;
int main()
{
int n;
while(scanf("%d", &n)!=EOF)
{
int con = 0;
node a;
a.x = 4;
q.push(a);
a.x = 7;
q.push(a);
while(!q.empty())
{
node b = q.front();
q.pop();
if(b.x<=n)
{
node c;
c.x = b.x*10+4;
q.push(c);
c.x = b.x*10+7;
q.push(c);
con++;
}
}
printf("%d\n", con);
}
return 0;
}