这题稍微有点难度(for新手)
点击跳转>>P1618 三连击(升级版) - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
上题解:
#include<bits/stdc++.h>
using namespace std;
int a[10],b1,b2,b3,l,k1,k2,k3,ans;
int main ()
{
cin >>k1>>k2>>k3;
for (int b=1;b<=1000/k3;++b)
{
b1=b*k1;
b2=b*k2;
b3=b*k3;
if (b2>999||b3>999)break;
for (int c=1;c<=3;++c)
{
a[b1%10]++;
b1/=10;
}
for (int c=1;c<=3;++c)
{
a[b2%10]++;
b2/=10;
}
for (int c=1;c<=3;++c)
{
a[b3%10]++;
b3/=10;
}
for (int c=1;c<=9;++c)if (a[c]!=1){l=1;break;}
for (int c=1;c<=9;++c)a[c]=0;
if (!l){cout <<b*k1 <<" " <<b*k2 <<" " <<b*k3 <<endl;ans++;}
else l=0;
}
if (!ans)cout <<"No!!!";
return 0;
}
拿走不谢
标签:连击,int,P1618,k3,b3,升级版 From: https://www.cnblogs.com/-Curry-/p/17232696.html