幸运数字c语言编程软件,幸运数 (C++代码)

解题思路:

注意事项:

参考代码:

#include

using namespace std;

const int M=500000;

int a[M],count;

void Lucky_number(int *s, int t, int n)

{

if(t==n) return ;

for(int i=1; ;i++)

{

int m=i*s[t];

if(m>n) break;

s[m-1]=0;

}

count=0;

for(int i=0; i

{

if(s[i]!=0)

s[count++]=s[i];

}

Lucky_number(s, t+1, count);

}

int main()

{

int M,N;

while(cin>>M>>N)

{

int n=0;

while((2*n+1) < N)

{

a[n]=2*n+1;

n++;

}

Lucky_number(a,1,n);

int t1=0;

for(int i=0; i

{

if(a[i]>M && a[i]

t1++;

}

cout<

}

return 0;

}