#include<bits/stdc++.h>usingnamespace std;char ans[11]="0123456789";char s[11];intmain(){#ifdef LOCALfreopen("E:\\Cpp\\1.in","r",stdin);#endifint n, pro, m =0;bool flag =false;while(~scanf("%d",&n)&& n){if(m++)printf("\n");
flag =false;for(int i =1234; i <49876; i++){// 2<=n<=79
pro = n * i;if(pro >98765)break;if(i <10000)sprintf(s,"0%d%d", i, pro);elsesprintf(s,"%d%d", i, pro);sort(s, s +10);if(strcmp(s, ans)==0){printf("%d / %05d = %d\n", pro, i, n);
flag =true;}}if(!flag)printf("There are no solutions for %d.\n", n);}return0;}
给出k, 求满足1/k = 1/x + 1/y的x和y
#include<cstdio>usingnamespace std;constint maxn =10005;constdouble eps =1e-6;int ansx[maxn], ansy[maxn];intmain(){#ifdef LOCALfreopen("E:\\Cpp\\1.in","r",stdin);#endifint k, x, y;double tmp;while(~scanf("%d",&k)){int cnt =0;for(y = k +1; y <=2* k; y++){
tmp =(double)k * y /(y - k);
x =(int)tmp;if(tmp - x < eps){
ansx[cnt]= x;
ansy[cnt]= y;
cnt++;}}printf("%d\n", cnt);for(int i =0; i < cnt; i++)printf("1/%d = 1/%d + 1/%d\n", k, ansx[i], ansy[i]);}return0;}