给定一个正整数k,问有多少个正整数x,y满足x>=y且1/k=1/x+1/y,并且x与y不互质,将所有解按x升序输出。
试补全程序。
#include<bits/stdc++.h> using namespace std; struct node{ int x, y; }; bool cmp (node a, node b){ return __(1)__; } bool check(int x, int y)//判断x与y是否互质 { for(int i = 2; i <= min(x, y); i++){ if(__(2)__) return false; } return true; } int main() { int k; vector<node> ans; cin>>k; for(int y = 1; y <= 2 * k; y++){ if(y - k <= 0){ continue; } int x = __(3)__; if(__(4)__){ ans.push_back(node{x, y}); } } sort(__(5)__); for(int i = 0; i < ans.size(); i++) cout<<ans[i].x<<" "<<ans[i].y<<endl; }