3544 - 桥本分数式
时间限制 : 1 秒
内存限制 : 128 MB
日本数学家桥本吉彦教授于1993年10月在我国山东举行的中日美三国数学教育研讨会上向与会者提出以下填数趣题:把1~9这9个数字填入下式的9个方格中(数字不得重复),使下面的分数等式成立
桥本教授当即给出了一个解答。
1/32+5/96=7/84
这一分数式填数趣题究竟共有多少个解答?
试求出所有解答,每个占一行(等式左边两个分数交换次序只算一个解答)。
<img style="height:139px;width:249px;" alt="" src="http://tk.hustoj.com:80/attached/image/20141219/20141219013449_41394.png" width="503" height="272" />
题目输入
题目输出
输入/输出样例
输入格式
no input needed
输出格式
1/26+5/78=4/39 1/32+5/96=7/84 1/32+7/96=5/48 1/78+4/39=6/52 1/96+7/48=5/32 2/68+9/34=5/17 2/68+9/51=7/34 4/56+7/98=3/21 5/26+9/78=4/13 6/34+8/51=9/27
C++解答
#include <stdio.h> #include <algorithm> #include <iostream> using namespace std; #define N 9 int p[N]; int main() { int x,y,z; for(int i=0;i<N;i++) p[i]=i+1; do { x=p[1]*10+p[2]; y=p[4]*10+p[5]; z=p[7]*10+p[8]; if((p[0]<p[3])&&((p[0]*y*z+p[3]*x*z)==p[6]*x*y)) printf("%d/%d%d+%d/%d%d=%d/%d%d\n",p[0],p[1],p[2],p[3],p[4],p[5],p[6],p[7],p[8]); } while(next_permutation(p,p+N)); return 0; }