UVA - 10976 Fractions Again?!(水题)
水题:直接从k+1到2*k枚举即可
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b,a) for(int i=b;i>=a;i--)
using namespace std;
const int N=1e5+100;
int arr[N];
int main()
{
ios::sync_with_stdio(false);
int k;
while(cin>>k)
{
int j=k+1;
int cnt=0;
map<int,int>mp;
while(j<=2*k)
{
int a=j*k;
int b=j-k;
if(a%b==0&&a/b>=j)
{
//cout<<"1/"<<k<<" = 1/"<<a/b>>" + 1/"<<j<<endl;
mp[j]=a/b;
cnt++;
}
j++;
}
cout<<cnt<<endl;
for(int i=k+1;i<=2*k;i++)
{
if(mp[i])
cout<<"1/"<<k<<" = 1/"<<mp[i]<<" + 1/"<<i<<endl;
}
}
return 0;
}