Lucky Mask
题解:
这个题一开始我以为是找规律一直没过,想用暴力做又怕会超时
看了网上大佬的思路发现是用暴力做的,过了
把每一个都循环一下,每一次都+1
再找到相应数的幸运值
然后在和题目中给出的那个值做对比
如果相等就输出
注意:
一定要从给定的那个数的下一个数来判断,因为题目中给出的条件是number c (c > a)
一个输入的时候用int类型一个用string类型
#include<bits/stdc++.h>
using namespace std;
string fin(int a)
{
string ret;
while (a!=0)
{
if (a%10==4||a%10==7)
{
ret=ret+((a%10)+'0');
}
a=a/10;
}
reverse(ret.begin(),ret.end());//转置函数(对字符串进行操作)
return ret;
}
int main()
{
int a;
string b;
cin>>a>>b;
int res=a+1;
while (fin(res)!=b)
{
res++;
}
cout<<res<<endl;
return 0;
}