40分求助

P1618 三连击(升级版)

糖果小屋 @ 2022-05-31 21:04:01

#include<iostream>
#include<algorithm>
using namespace std;
int a[10];
int main(){
    long long a1,b,c,x,y,z,cnt = 0;
    cin>>a1>>b>>c;
    for(int i=1;i<=9;i++){
        a[i] = 1;
    }
    do{
        x = a[1] * 100 + a[2] * 10 + a[3];
        y = a[4] * 100 + a[5] * 10 + a[6];
        z = a[7] * 100 + a[8] * 10 + a[9];
        if(x*b==y*a1&&y*c==z*b){
            cout<<x<<" "<<y<<" "<<z<<" ";
            cnt++;
        }
    }while(next_permutation(a+1,a+10));
    if(!cnt){
        cout<<"No!!!";
    }
} 

by ajahjahah @ 2022-05-31 21:05:42

问题很显然

for(int i=1;i<=9;i++){
    a[i] = 1;
}

先测一遍样例再问


by NOI_AK_ME @ 2022-05-31 21:07:02

样例好像没过,8~10行明显出问题


by A1438329629 @ 2022-05-31 21:21:41

这里


|