100,但是#1RE

P1618 三连击(升级版)

yashi258 @ 2024-02-14 17:31:13

#include<iostream>

using namespace std;
bool check(int arr[])
{
    for (int i = 1; i <= 9; i++)
    {
        int k = 0;
        for (int j = 0; j < 9; j++)
        {
            if (i == arr[j])
                k += 1;
        }
        if (k != 1)
            return false;
    }
    return true;
}
int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    int sum = 0;
    for (int i = 123; i <= 987; i++)
    {
        int j = i * y / x;  //但是这里可能是忽略小数
        j = (j * x == i * y ? j : j + 1);
        int k = i * z / x;
        k = (k * x == i * z ? k : k + 1);
        int arr[9];
        arr[0] = i / 100;
        arr[1] = i % 100 / 10;
        arr[2] = i % 10;
        arr[3] = j / 100;
        arr[4] = j % 100 / 10;
        arr[5] = j % 10;
        arr[6] =  k/ 100;
        arr[7] = k % 100 / 10;
        arr[8] = k % 10;
        //判断
        if (check(arr))
        {
            sum += 1;
            cout << i << " " << j << " "<<k << endl;
        }
    }
    if (sum == 0)
        cout << "No!!!";
}

by Albatross_LC @ 2024-02-14 17:36:02

要特判


by Albatross_LC @ 2024-02-14 17:36:37

@yashi258 x等于零时直接输出No!!!


by yashi258 @ 2024-02-14 17:37:50

@Albatross_LC 谢谢大佬,已经改过来ac了


|