这是什么操作求解

P1618 三连击(升级版)

Umaru @ 2017-07-05 16:19:57

#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<cstring> 
#include<algorithm>
using namespace std;
int i=0,j=0,num[4],a,b,c;
int ject[7];
bool ans,yes;
int main()
{
    cin>>a>>b>>c;
    for (i=190;i<=229;i++)
    {
        num[1]=(i%10);
        num[2]=(i%100/10);
        num[3]=(i/100);
        ject[1]=num[1]*a;
        ject[2]=num[2]*a;
        ject[3]=num[3]*a;
        ject[4]=num[1]*b;
        ject[5]=num[2]*b;
        ject[6]=num[3]*b;
        ject[7]=num[1]*c;
        ject[8]=num[2]*c;
        ject[9]=num[3]*c;
        sort(ject+1,ject+10);
        ans=true;
        for (j=1;j<10;j++){
            int he=0,ji=1;
            he+=num[j];
            ji*=num[j];
            if(he!=45&&ji!=362880)
            ans=false;
        }
        if (ans) {
        cout<<i*a<<" "<<i*b<<" "<<i*c<<endl;
        yes=true;
        }
    }
    if(!yes){
        cout<<"No!!!";
    }
    return 0;
}
//调试的时候num和ject都没有被赋值什么情况啊思路应该没错啊???

by Umaru @ 2017-07-05 16:43:28

自改了一波还是有问题

#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<cstring> 
#include<algorithm>
using namespace std;
int i=0,j=0,a,b,c,ji,he;
int ject[11];
bool ans,yes;
int main()
{
    cin>>a>>b>>c;
    for (i=191;i<=329;i++)
    {
        ject[1]=(i%10);
        ject[2]=(i%100/10);
        ject[3]=(i/100);
        ject[4]=ject[1]*b/a;
        ject[5]=ject[2]*b/a;
        ject[6]=ject[3]*b/a;
        ject[7]=ject[1]*c/a;
        ject[8]=ject[2]*c/a;
        ject[9]=ject[3]*c/a;
        sort(ject+1,ject+10);
        ans=true;
        he=0,ji=1;
        for (j=1;j<10;j++){
            he+=ject[j];
            ji*=ject[j];
            if(he!=45&&ji!=362880)
            ans=false;
        }
        if (ans) {
        cout<<i<<" "<<i*b/a<<" "<<i*c/a<<endl;
        yes=true;
        }
    }
    if(!yes){
        cout<<"No!!!";
    }
    return 0;
}

by Umaru @ 2017-07-06 16:19:08

自改成功

#include<iostream>
#include<cstdio>
#include<iomanip>
#include<cmath>
#include<cstring> 
#include<algorithm>
using namespace std;
int i=0,j=0,a,b,c,ji,he;
int ject[11];
bool ans,yes;
int main()
{
    cin>>a>>b>>c;
    for (i=123;i<=329;i++)
    {
        ans=false;
        ject[1]=(i%10);
        ject[2]=(i%100/10);
        ject[3]=(i/100);
        ject[4]=i*b/a%10;
        ject[5]=i*b/a%100/10;
        ject[6]=i*b/a/100;
        ject[7]=i*c/a%10;
        ject[8]=i*c/a%100/10;
        ject[9]=i*c/a/100;
        sort(ject+1,ject+10);
        he=0,ji=1;
        for (j=1;j<10;j++){
            he+=ject[j];
            ji*=ject[j];
            if(he==45&&ji==362880)
            ans=true;
        }
        if (ans) {
        cout<<i<<" "<<i*b/a<<" "<<i*c/a<<endl;
        yes=true;
        }
    }
    if(!yes){
        cout<<"No!!!";
    }
    return 0;
}

|