标签:style color io os ar for 数据 div sp
现在输入一个正整数k,找到所有的正整数x>=y,使得1/k=1/x+1/y.
2 2 12
1/2=1/6+1/3 1/2=1/4+1/4 1/12=1/156+1/13 1/12=1/84+1/14 1/12=1/60+1/15 1/12=1/48+1/16 1/12=1/36+1/18 1/12=1/30+1/20 1/12=1/28+1/21 1/12=1/24+1/24
代码:
#include<stdio.h> int main() { int n,k,i; scanf("%d",&n); while(n--) { scanf("%d",&k); for(i=k+1;i<=2*k;++i) { if(k*i%(i-k)==0) printf("1/%d=1/%d+1/%d\n",k,k*i/(i-k),i); } } return 0; }
标签:style color io os ar for 数据 div sp
原文地址:http://blog.csdn.net/qq_18062811/article/details/39213187