卡在60分了,哪位大佬帮我看看,感激不尽

P1618 三连击(升级版)

lizaigaoge550 @ 2017-10-26 19:49:13

#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
using namespace std;
int arr[10];
int main(){
    int a, b, c;
    int index = 1;
    scanf("%d%d%d", &a, &b, &c);
    int max_v = 987 * a / c;
    for (int i = 123; i <= max_v; i++){
        int co = 1;
        if (i%a == 0){
            int it = i / a;
            arr[co++] = a*it % 10;
            arr[co++] = a*it % 100 / 10;
            arr[co++] = a*it / 100;
            arr[co++] = b*it % 10;
            arr[co++] = b*it % 100 / 10;
            arr[co++] = b*it / 100;
            arr[co++] = c*it % 10;
            arr[co++] = c*it % 100 / 10;
            arr[co++] = c*it / 100;
            sort(arr + 1, arr + 10);
            int flag = 1;
            for (int j = 1; j <= 9; j++){
                if (j != arr[j]){
                    flag = 0;
                    break;
                }
            }
            if (flag){
                printf("%d %d %d\n",a*it,b*it,c*it);
            }
        }
    }
    //system("pause");
    return 0;
}

by Ervin @ 2017-10-26 20:08:36

。。。可能是你没有看清题意。。题目上说:”无解则输出'No!!!'“。加上一个变量,判断一下就AC了


by lizaigaoge550 @ 2017-10-27 08:02:58

谢谢!!!!! @GYT_Dada


|