这次更惨wa声一片,求神犇摘错yyy

P1618 三连击(升级版)

森森鸭 @ 2019-08-02 19:27:58

话不多说直接上代码

#include<iostream>
using namespace std;
int b1,b2,b3,l,k1,k2,k3,ans=0;
int gw(int a) {return a%10;}
int sw(int a) {return a/10%10;}
int bw(int a) {return a/100;}
int main ()
{
    cin >>k1>>k2>>k3;
    for (int b=12;b<=329;b++)
    {
        b1=b*k1;
        b2=b*k2;
        b3=b*k3; 
        if(b1<123) continue;if(b3>987)continue;
        if(gw(b1)!=sw(b1)!=bw(b1)!=gw(b2)!=sw(b2)!=bw(b2)!=gw(b3)!=sw(b3)!=bw(b3))
        {
            cout<<b1<<" "<<b2<<" "<<b3<<endl;
            ans=1;
        }
    }
    if (ans==0)cout <<"No!!!";
    return 0;
}

by VTloBong @ 2019-08-02 20:05:34

if(gw(b1)!=sw(b1)!=bw(b1)!=gw(b2)!=sw(b2)!=bw(b2)!=gw(b3)!=sw(b3)!=bw(b3))

这个if语句不对。

if(a!=b!=c) 相当于if(a!=b&&b!=c) 不能判断a!=c


by VTloBong @ 2019-08-02 20:16:53

@森森鸭


by 森森鸭 @ 2019-08-02 21:05:41

@123456L 好的谢谢!!!


by 森森鸭 @ 2019-08-02 21:26:10

#include<iostream>
using namespace std;
int b1,b2,b3,l,k1,k2,k3,ans=0;
int gw(int a) {return a%10;}
int sw(int a) {return a/10%10;}
int bw(int a) {return a/100;}
int main ()
{
    cin >>k1>>k2>>k3;
    for (int b=12;b<=329;b++)
    {
        b1=b*k1;
        b2=b*k2;
        b3=b*k3; 
        if(b1<123) continue;if(b3>987)continue;
        if(gw(b1)!=sw(b1)&&gw(b1)!=bw(b1)&&gw(b1)!=gw(b2)&&gw(b1)!=sw(b2)&&gw(b1)!=bw(b2)&&gw(b1)!=gw(b3)&&gw(b1)!=sw(b3)&&gw(b1)!=bw(b3)&&sw(b1)!=bw(b1)&&sw(b1)!=gw(b2)&&sw(b1)!=sw(b2)&&sw(b1)!=bw(b2)&&sw(b1)!=gw(b3)&&sw(b1)!=sw(b3)&&sw(b1)!=bw(b3)&&bw(b1)!=gw(b2)&&bw(b1)!=sw(b2)&&bw(b1)!=bw(b2)&&bw(b1)!=gw(b3)&&bw(b1)!=sw(b3)&&bw(b1)!=bw(b3)&&gw(b2)!=sw(b2)&&gw(b2)!=bw(b2)&&gw(b2)!=gw(b3)&&gw(b2)!=sw(b3)&&gw(b2)!=bw(b3)&&sw(b2)!=bw(b2)&&sw(b2)!=gw(b3)&&sw(b2)!=sw(b3)&&sw(b2)!=bw(b3)&&bw(b2)!=gw(b3)&&bw(b2)!=sw(b3)&&bw(b2)!=bw(b3)&&gw(b3)!=sw(b3)&&gw(b3)!=bw(b3)&&sw(b3)!=bw(b3))
        {
            cout<<b1<<" "<<b2<<" "<<b3<<endl;
            ans=1;
        }
    }
    if (ans==0)cout <<"No!!!";
    return 0;
}

@123456L


by 森森鸭 @ 2019-08-02 21:26:39

@123456L 囧爆,60score


|