czk15 @ 2017-08-18 19:38:57
#include<bits/stdc++.h>
using namespace std;
int bb(int a,int b,int c)
{
int n[10],i=1;
while(a){ n[i++]=a%10; a/=10; }
while(b){ n[i++]=b%10; b/=10; }
while(c){ n[i++]=c%10; c/=10; }
for(int i=1;i<=9;i++)
for(int j=i+1;j<=9;j++)
if(n[i]==n[j]) return 0;
for(int i=1;i<=9;i++)
if(n[i]==0) return 0;
return 1;
}
int ll(int a)
{
int i=0;
while(a)
{
a/=10;
i++;
}
return i;
}
int aa(int a,int b,int c)
{
if(ll(a)==3&&ll(b)==3&&ll(c)==3) return 1;
else return 0;
}
int main()
{
int t1,t2,t3,a,b,c,t=1;
cin>>a>>b>>c;
for(int i1=1;i1<=9;i1++)
for(int i2=1;i2<=9;i2++)
for(int i3=1;i3<=9;i3++){
t1=i1*100+i2*10+i3; t2=t1/a*b; t3=t1/a*c;
if(aa(t1,t2,t3)&&bb(t1,t2,t3)){ cout<<t1<<" "<<t2<<" "<<t3<<endl; t=0; }}
if(t) cout<<"No!!!";
} //最后一个测试点过不了
by ty520 @ 2017-08-18 22:08:33
我也是的 表示很无奈
by KesdiaelKen @ 2017-08-18 22:19:03
我也很无奈啊,只能发上个AC代码了,跟你的对比一下了。
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
int a,b,c;
bool yg[10]={0};
bool y=false;
void cal(int shu)
{
if(shu>=123456789)
{
int A=shu/1000000%1000,B=shu/1000%1000,C=shu%1000;
if(double(A)/double(a)==double(B)/double(b)&&double(B)/double(b)==double(C)/double(c))
{
cout<<A<<" "<<B<<" "<<C<<endl;
y=true;
}
}
else
{
for(int i=1;i<=9;i++)
{
if(!yg[i])
{
yg[i]=true;
cal(shu*10+i);
yg[i]=false;
}
}
}
}
int main()
{
cin>>a>>b>>c;
cal(0);
if(y==false)cout<<"No!!!";
}
by xtx2004 @ 2017-09-03 16:50:20
#include <bits/stdc++.h>
using namespace std;
char standard[]="123456789";
int main()
{
int a,b,c,flag=1;
scanf("%d%d%d",&a,&b,&c);
for(int i=1;i<=329;i++){
char buf[20];
//if(a*i>987||b*i>987||c*i>987) break;
sprintf(buf,"%d%d%d",a*i,b*i,c*i);
sort(buf,buf+9);
if(strcmp(standard,buf)==0) {flag=0;printf("%d %d %d\n",a*i,b*i,c*i);}
}
if(flag) printf("No!!!\n");
return 0;
}
**嘻嘻~**
by 皮皮虾letusgo @ 2017-09-09 19:21:51
我也是80分o(╥﹏╥)o
代码如下:
#include <iostream>
#include <cstring>
using namespace std;
int main ()
{
int x,y,z,a,b,c,p[10];
bool ok2=0;
cin>>x>>y>>z;
memset (p,0,sizeof (p));
for (int i=1;i<=3;i++)
{
for (int j=1;j<=9;j++)
{
for (int k=1;k<=9;k++)
{
memset (p,0,sizeof (p));
bool ok=1;
if (i==j||j==k||i==k) ok=0;
a=i*100+j*10+k;
b=a/x*y;c=a/x*z;
if (b>999||c>999) ok=0;
p[i]=1;p[j]=1;p[k]=1;
p[b/100]=1;p[b/10%10]=1;p[b%10]=1;
p[c/100]=1;p[c/10%10]=1;p[c%10]=1;
for (int q=1;q<=9;q++)
if (p[q]==0) ok=0;
if (ok) {ok2=1;cout<<a<<' '<<b<<' '<<c<<endl;}
}
}
}
if (!ok2) cout<<"no!!!"<<endl;
return 0;
}
by 皮皮虾letusgo @ 2017-09-09 19:23:22
N大写,之前打错了