首页 > 其他 > 详细

UVA 10976 Fractions Again?! 简单枚举题

时间:2016-08-21 19:51:54      阅读:186      评论:0      收藏:0      [点我收藏+]
#include<stdio.h>
struct pairs{
    int x,y;
};
struct pairs pairs[10000];

int judge(int k,int i){
    if((k*i)%(i-k)==0)
    return 1;
    else
    return 0;
}

int main(){
    int k,count;
    while(scanf("%d",&k)!=EOF){
       count=0;
       for(int i=k+1;i<=2*k;i++){
          if(judge(k,i)){
            count++;      
            pairs[count].x=k*i/(i-k);
            pairs[count].y=i;
            }
        }
    
        printf("%d\n",count);
        for(int i=1;i<=count;i++){
        printf("1/%d = 1/%d + 1/%d\n",k,pairs[i].x,pairs[i].y);
        }        
    }
    return 0;
}

 

UVA 10976 Fractions Again?! 简单枚举题

原文:http://www.cnblogs.com/lsj2020/p/5793243.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!