首页 > 其他 > 详细

Codeforces Round #104 (Div.2)

时间:2020-12-20 23:13:13      阅读:34      评论:0      收藏:0      [点我收藏+]

B - Lucky Mask

 题意:就是给一个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;
}

 

Codeforces Round #104 (Div.2)

原文:https://www.cnblogs.com/liyongqi/p/14165606.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!