游客 Signup | Login
中文 | En

3211 - ADV-83 寻找三位数

将1,2,…,9共9个数分成三组,分别组成三个三位数,且使这三个三位数构成
  1:2:3的比例,试求出所有满足条件的三个三位数。
  例如:三个三位数192,384,576满足以上条件。

Input

 无输入文件

Output

输出每行有三个数,为满足题设三位数。各行为满足要求的不同解。

Examples

Input


                

Output


                

Solution C++

#include <iostream>
#include <algorithm>
using namespace std;
int p[9]={1,2,3,4,5,6,7,8,9};
int main()
{
	do
	{
		int x = p[0]*100+p[1]*10+p[2];
		int y = p[3]*100+p[4]*10+p[5];
		int z = p[6]*100+p[7]*10+p[8];
		if(2*x==y&&3*x==z)
			cout<<x<<" "<<y<<" "<<z<<endl;
			
	}
	while(next_permutation(p,p+9));
	return 0;
}

Time Limit 1 second
Memory Limit 128 MB
Discuss Stats
上一题 下一题