Thuật toán: Cài đặt như yêu cầu bài toán.
Code:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<set>
#include<vector>
#include<utility>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
using namespace std;
#define oo 1000000005
#define rep(i,s,e) for(int i = s; i < e; i++)
#define lop(i,s,e) for(int i = s; i != e; i++)
#define FOR(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end(); it++)
#define SZ(x) ((int)(x).size())
#define X first
#define Y second
typedef pair<int,int> II;
typedef pair<II,int> D;
typedef long long LL;
vector<int> V;
map<int,int> M;
set<int> S;
queue<int> Q;
stack<int> ST;
int mask(int _a)
{
int _res = 0;
for(;_a;_a/=10)
{
int x = _a % 10;
if(x == 4 || x == 7)
{
_res = _res * 10 + x;
}
}
return _res;
}
int main()
{
#define Off true
if(Off)
{
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
}
int a,b;
cin >> a >> b;
b = mask(b);
// cout << mask(12407);
lop(c,a+1,-1)
if(mask(c) == b)
{
cout << c;
break;
}
return 0;
}
Không có nhận xét nào:
Đăng nhận xét