题目
由于 x > = y x>=y x>=y,有 1 / x < = 1 / y 1/x<=1/y 1/x<=1/y,因此 y < − 2 k y<-2k y<−2k.这样,只需 2 k 2k 2k范围之内枚举 y y y,然后算出 x x x即可
提示:以下是本篇文章正文内容,下面案例可供参考
代码
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <math.h>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long ll;
int main()
{
int k,t=0;
while(scanf("%d",&k) == 1){
int xx[100],yy[100];
t=0;
for(int y=k+1;y<=2*k;y++)
if(y*k%(y-k)==0)
{
t++;
xx[t]=y*k/(y-k);
yy[t]=y;
}
cout<<t<<endl;
for(int i=1;i<=t;i++)
printf("1/%d=1/%d+1/%d\n",k,xx[i],yy[i]);
}
return 0;
}