如果一个数字中有7,我们就认为他是幸运数字。
给出两个整数L, R(1<=L<=R<=100000)
请从小到大输出所有满足L<=n<=R的幸运数字n,每个数占一行。
特别注意如果区间内没有任何一个幸运数字,输出None
Input
一行两个整数L, R,其中1≤L≤R≤100000。
Output
从小到大输出所有幸运数字,一行一个。 特别注意如果区间内没有任何一个幸运数字,输出None
Sample
Input | Output |
---|---|
88 111 | 97 107 |
Time limit | 1000 ms |
Memory | 131072 kB |
话不多说,上代码:
#include<bits/stdc++.h>
using namespace std;
int main() {
int a,b,j,x,g=0;
cin>>a>>b;
for(int i=a; i<=b; i++) {
j=i;
while(j>0) {
x=j%10;
if(x==7) {
cout<<i<<endl;
g=1;
break;
}
j/=10;
}
}
if(g==0)
cout<<"None";
}