KK爱搞机 @ 2016-11-05 11:20:33
#include<iostream>
#include<cstring>
using namespace std;
int num[10000001],a,b,c,flag=0;
int main(){
cin>>a>>b>>c;
for(int n1=1;n1<=9;n1++)
for(int n2=1;n2<=9;n2++)
for(int n3=1;n3<=9;n3++)
for(int n4=1;n4<=9;n4++)
for(int n5=1;n5<=9;n5++)
for(int n6=1;n6<=9;n6++)
for(int n7=1;n7<=9;n7++)
for(int n8=1;n8<=9;n8++)
for(int n9=1;n9<=9;n9++)
if(n1!=n2&&n1!=n3&&n1!=n4&&n1!=n5&&n1!=n6&&n1!=n7&&n1!=n8&&n1!=n9
&&n2!=n3&&n2!=n4&&n2!=n5&&n2!=n6&&n2!=n7&&n2!=n8&&n2!=n9
&&n3!=n4&&n3!=n5&&n3!=n6&&n3!=n7&&n3!=n8&&n3!=n9
&&n4!=n5&&n4!=n6&&n4!=n7&&n4!=n8&&n4!=n9
&&n5!=n6&&n5!=n7&&n5!=n8&&n5!=n9
&&n6!=n7&&n6!=n8&&n6!=n9
&&n7!=n8&&n7!=n9
&&n8!=n9
&&(n1*100+n2*10+n3)/a==(n4*100+n5*10+n6)/b==(n7*100+n8*10+n9)/c){
cout<<n1*100+n2*10+n3<<" "<<(n4*100+n5*10+n6)<<" "<<(n7*100+n8*10+n9)<<endl;
flag=1;
}
if(flag==0)cout<<"No!!!";
return 0;
}
by __世界第一弱__ @ 2016-11-05 11:50:38
帮你加O3(滑稽)
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
#define reg register
#define For(a,b,c) for(reg int a=b;i<=c;i++)
#define O(x) __attribute__((optimize("-O"#x)))
#define inline O(3)
int a,b,c,flag=0;
inline int main() {
cin>>a>>b>>c;
for(int n1=1; n1<=9; n1++)
for(int n2=1; n2<=9; n2++)
for(int n3=1; n3<=9; n3++)
for(int n4=1; n4<=9; n4++)
for(int n5=1; n5<=9; n5++)
for(int n6=1; n6<=9; n6++)
for(int n7=1; n7<=9; n7++)
for(int n8=1; n8<=9; n8++)
for(int n9=1; n9<=9; n9++)
if(n1!=n2&&n1!=n3&&n1!=n4&&n1!=n5&&n1!=n6&&n1!=n7&&n1!=n8&&n1!=n9
&&n2!=n3&&n2!=n4&&n2!=n5&&n2!=n6&&n2!=n7&&n2!=n8&&n2!=n9
&&n3!=n4&&n3!=n5&&n3!=n6&&n3!=n7&&n3!=n8&&n3!=n9
&&n4!=n5&&n4!=n6&&n4!=n7&&n4!=n8&&n4!=n9
&&n5!=n6&&n5!=n7&&n5!=n8&&n5!=n9
&&n6!=n7&&n6!=n8&&n6!=n9
&&n7!=n8&&n7!=n9
&&n8!=n9
&&(n1*100+n2*10+n3)/a==(n4*100+n5*10+n6)/b==(n7*100+n8*10+n9)/c) {
cout<<n1*100+n2*10+n3<<" "<<(n4*100+n5*10+n6)<<" "<<(n7*100+n8*10+n9)<<endl;
flag=1;
}
if(flag==0)cout<<"No!!!";
return 0;
}
by Lolierl @ 2016-11-05 18:05:44
@KK爱搞机
把循环下限设为上一个变量+1,就不用if了
by KK爱搞机 @ 2016-11-05 23:08:04
谢谢