2,4,5都没过,帮看下

P1618 三连击(升级版)

Jamison_Tam @ 2023-02-09 00:13:14

#define _CRT_SECURE_NO_DEPRECATE
#include<iostream>
#include<vector>
#include<cmath>
#include<iomanip>
#include <sstream>
#include<algorithm>
#include <cstdio>
#include<string>
int main() {
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    int t = 0;
    int num = 123;
    while (num <= 987&&a>0) {
        int n1 = num;
        int n[10];
        for (int i = 1; i < 10; i++)
            n[i] = 0;
        int tt = 3;
        int nn[3];
        while (tt > 0&&num>=123&&num<=987) {
            int x = num / 100, y = (num % 100) / 10, z = num %10;
            if (x == 0 || y == 0 || z == 0)
                break;
            if (n[x] == 0 && n[y] == 0 && n[z] == 0&&x!=y&&x!=z&&y!=z)
            {
                n[x] = n[y] = n[z] = 1;
                nn[tt-1] = num;
            }
            else
                break;
            if (tt == 3)
                num = (num * b) / a;
            else
                num = (n1 * c) / a;
            tt--;
        }
        if (tt == 0)
            printf("%d %d %d\n", nn[2], nn[1], nn[0]);
        t++;
        num =n1+1;
    }
    if (t == 0)
        printf("No!!!");
}

by Tx1234567 @ 2023-02-09 08:14:18

c!!!


by 编码落寞 @ 2023-02-09 08:30:55

@Jamison_Tam

你的外层循环一直在跑,t的值一直再加。 然后判无解的方式有问题


|