3 条题解
-
1
2.8洛谷讨论区倒闭来的本人的第1篇题解思路
这题只需要枚举的值就行了,然后把数字拆分后用桶的思想挨个检查即可。 至于a的枚举范围从最小(123)到 1000/3 就行。 一定记得清0!
Code
#include<bits/stdc++.h> using namespace std; int hydro[11]; // 用桶的思想来检查是否每个数只用一次 int main(){ for(int a=123;a<=1000/3;a++){ memset(hydro,0,sizeof(hydro));//一定记得清0! int b = 2*a; int c = 3*a; /* 三位数的拆分: 个位:x(/1)%10 十位:x/10%10 百位:x/100(%10) */ hydro[a/100]++; hydro[a/10%10]++; hydro[a%10]++; hydro[b/100]++; hydro[b/10%10]++; hydro[b%10]++; hydro[c/100]++; hydro[c/10%10]++; hydro[c%10]++; bool flag = true; for(int i=1;i<=9;i++){ if(hydro[i] != 1){ flag = false; } } if(flag == true){ cout << a << " " << b << " " << c << endl; } } return 0; } /* 附上自己算的: 192 384 576 219 438 657 273 546 819 327 654 981 */
信息
- ID
- 5066
- 时间
- 1000ms
- 内存
- 64MiB
- 难度
- 2
- 标签
- 递交数
- 594
- 已通过
- 319
- 上传者