Codeforces Round #104 (Div.2)

B - Lucky Mask

 CodeForces - 146B 

#include<bits/stdc++.h>
#define ll long long
using namespace std;
#define speed_up ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
/*
刚开始用了很多方法都做不出来,后来看了别人的代码。这个做法主要是用了一个字符串转置函数和暴力
*/
string f(int a)//对每一个数进行判断
{
string s;//定义一个空串
while(a)
{
if(a%10==4||a%10==7)
{
s+=((a%10)+'0');//相当于只留下这个数中带有的4和7
}
a/=10;
}
reverse(s.begin(),s.end());//因为是从后往前判断的,所以要反转字符串
return s;
}
int main()
{
int a;
string b;
cin>>a>>b;
int x=a+1;//定义一个比a大1的x
while(f(x)!=b)//返回的字符串和b相等就输出这个数
{
x++;
}
cout<<x<<endl;
}

posted @ 2020-12-20 19:51  SyrupWRLD  阅读(68)  评论(0)    收藏  举报