洛谷P1618

洛谷P1618

暴力即可!!!

#include
using namespace std;
typedef long long ll;
const int maxn = 1e4+100;
int main()
{
     
    int a, b, c;
    int temp[10] = {
     0};
    int ans1, ans2, ans3;
    int flag = 1, count = 0;
    cin >> a >> b >> c;
    for (int i = 123; i <= 987; i++)
    {
     
        fill(temp,temp+10,0);
        flag = 1;
        ans1 = i;
        ans2 = 1.0 * i / a * b;
        ans3 = 1.0 * i / a * c;
        int x = ans1;
        if (ans2 >= 1000 || ans3 >= 1000)
            continue;
        while (x > 0)
        {
     
            temp[x%10] ++;
            x = x / 10;
        }
        x = ans2;
        while (x > 0)
        {
     
            temp[x%10] ++;
            x = x / 10;
        }
        x = ans3;
        while (x > 0)
        {
     
            temp[x%10] ++;
            x = x / 10;
        }
        for (int j = 1;j <= 9; j++)
        {
     
            if (temp[j] != 1)
                flag = 0;
        }
        if (flag == 1)
        {
     
            printf("%d %d %d\n",ans1,ans2,ans3);
            count ++;
        }
    }
    if (count == 0)
        printf("No!!!\n");
    return 0;
}

你可能感兴趣的:(洛谷P1618)