这题没有输入吧,你怎么cin>>a>>b>>c?
by xxk2006 @ 2023-12-30 12:05:19
@[AKioi0101](/user/759660) 发错题了吧。
by xiaoshumiao @ 2023-12-30 12:39:15
@[AKioi0101](/user/759660) 应该是[这道](https://www.luogu.com.cn/problem/P1618)。
特判 $a,b,c=0$ 的情况。
by xiaoshumiao @ 2023-12-30 12:40:46
@[AKioi0101](/user/759660) 你交错题了。
by xiaoshumiao @ 2023-12-30 12:41:57
```cpp
//避免枚举,用分离位数算法
#include<iostream>
#include<vector>
using namespace std;
#include<string>
//分离位数函数
vector<int> disassmeble(int u)
{
vector<int>c;
while (u)
{
c.push_back(u % 10);
u /= 10;
}
return c;
}
int main()
{
vector<int>A, B, C;
int b, c;
for (int a = 123; a <= 333; a++)
{
b = 2 * a;
c = 3 * a;
A = disassmeble(a);
B = disassmeble(b);
C = disassmeble(c);
int sum = 0;
int s = 1;
for (int i = 0; i < 3; i++)
{
sum += A[i] + B[i] + C[i];
}
for (int i = 0; i < 3; i++)
{
s *= A[i] * B[i] * C[i];
}
//1+2+..9=45 9!=362880
if (sum == 45 && s == 362880)
{
cout << a << " " << b << " " << c;
cout << endl;
}
}
return 0;
}
by swuster27 @ 2024-01-31 13:48:23
@[AKioi0101](/user/759660)
交错题了,这道[三连击(升级版)](https://www.luogu.com.cn/problem/P1618#submit)
by Dark_Monarch @ 2024-02-05 15:35:48
@[AKioi0101](/user/759660)
```cpp
#include<bits/stdc++.h>
using namespace std;
int A = 1,B = 2,C = 3;
int cnt[10];
bool check(int x){
if(A == 0) return false;
if(x * B % A != 0)
return false;
int y = x * B / A;
if(C * y % B != 0)
return false;
int z = C * y / B;/*判断x:y:z 是否等于A:B:C*/
if(y < 100 || y > 999) return false;
if(z < 100 || z > 999) return false;
memset(cnt,0,sizeof(cnt));/*清空*/
int x_ = x, y_ = y, z_ = z;/*备份*/
for(int i = 1;i <= 3;i++){
cnt[x % 10] ++; x /= 10;
cnt[y % 10] ++; y /= 10;
cnt[z % 10] ++; z /= 10;
}
for(int i = 1;i < 10;i++)
if(cnt[i] != 1)
return false;
cout << x_ << ' ' << y_ << ' ' << z_ << endl;
return true;
}
int main(){
int o = 0;
for(int x = 123;x <= 987;x++){
if(check(x))
o++;
}
if(o == 0){
cout << "No!!!";
}
return 0;
}
```
by Dark_Monarch @ 2024-02-05 15:36:35
@[xiaoshumiao](/user/1008513)
$hello$
by AC_710GD @ 2024-02-16 22:45:29
@[AKioi0101](/user/759660)
$三连击(升级版)里有我的求助$
$呵呵$
by AC_710GD @ 2024-02-16 22:46:19