Domoo @ 2023-07-16 11:02:07
RT,但是为什么用桶排序排重不加判断是WA,这种方法就是RE呢,不理解
#include<bits/stdc++.h>
using namespace std;
int d[10], a, b, c, x, y, z, f, r;
void chk(int n)
{
d[n/100] = d[n/10%10] = d[n%10] = 1;
}
int main()
{
cin >> a >> b >> c;
for(int i = 1; i < 765; i++)
{
x = i * a;
y = i * b;
z = i * c;
if(y > 999 || z > 999) break;//这里
chk(x);
chk(y);
chk(z);
for(int i = 1; i <= 9; i++)
if(d[i] == 0)
f = 1;
if(!f)
{
cout << x << " " << y << " " << z << '\n';
r = 1;
}
else f = 0;
memset(d, 0, sizeof(d));
}
if(!r)
cout << "No!!!" << '\n';
return 0;
}
by codejiahui @ 2023-07-16 11:20:47
@Domoo 因为如果y>999,y/100的结果大于9,会爆掉
by codejiahui @ 2023-07-16 11:21:15
@Domoo 如果我说的对,关注
一下谢谢
by Domoo @ 2023-07-16 11:23:30
@codejiahui 但是在自己的IDE上是可以正常运行的,就在洛谷IDE才不行
by codejiahui @ 2023-07-16 11:48:15
@Domoo IDE它好像会自己找一个在数组后的地址,但是洛谷上都判断RE
by wsbSB @ 2023-07-28 18:31:40
@Domoo 开O2优化