玄关求助
查看原帖
玄关求助
911026
jaspersgr114514楼主2024/9/22 13:37
#include <bits/stdc++.h>
using namespace std;
bool check(int x, int y, int z)
{
    bool use[10];
    memset(use, false, sizeof(use));
    while (x)
    {
        if (use[x % 10] == true || x % 10 == 0)
            return false;
        else
        {
            use[x % 10] = true;
            x /= 10;
        }
    }
    while (y)
    {
        if (use[y % 10] == true || y % 10 == 0)
            return false;
        else
        {
            use[y % 10] = true;
            y /= 10;
        }
    }
    while (z)
    {
        if (use[z % 10] == true || z % 10 == 0)
            return false;
        else
        {
            use[z % 10] = true;
            z /= 10;
        }
    }
    return true;
}
int main()
{
    int a, b, c;
    bool flag = false;
    cin >> a >> b >> c;
    for (int i = 100; i <= 333; i++)
    {
        if (i % a != 0)
            continue;
        int x = i;
        int y = i / a * b;
        int z = i / a * c;
        if (x >= 1000 || y >= 1000 || z >= 1000)
            continue;
        if (check(x, y, z))
        {
            flag = true;
            cout << x << ' ' << y << ' ' << z << endl;
        }
    }
    if (flag == false)
    {
        cout << "No!!!";
    }
}

2024/9/22 13:37
加载中...