题意:就是给一个a和b,寻找一个大于a的数并保证是b的幸运数。
题解:比赛的时候就以为是个规律题,一直找规律越找越乱,其实只要遍历比a大的所有结果就好,暴力tql。
代码
#include<iostream> #include<string> #include<algorithm> using namespace std; string mask(int a) { string ret; while (a) { if (a % 10 == 4 || a % 10 == 7) { ret += ((a % 10) + ‘0‘); } a /= 10; } reverse(ret.begin(),ret.end()); return ret; } int main() { int a; string b; cin >> a >> b; int res = a + 1; while (mask(res) != b) { res++; } cout << res << endl; return 0; }
原文:https://www.cnblogs.com/liyongqi/p/14165606.html