此题得注意到 y和k之间的关系,y > k 且y<= 2* k
然后就是枚举就行了
//
// main.cpp
// uva 10976 - Fractions Again?!
//
// Created by XD on 15/7/26.
// Copyright (c) 2015年 XD. All rights reserved.
//
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include<vector>
#include <string.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cstdio>
using namespace std ;
//int d[10010] ;
int main(int argc, const char * argv[]) {
int k ;
set<int > y ;
while(scanf("%d", &k)==1){
// int j = 0 ;
y.clear() ;
for (int i =k +1; i <=2*k; i++) {
if ((i* k) % (i- k)==0 ) {
// int x =(i* k) / (i- k) ;
// printf("1/%d = 1/%d + 1/%d\n" , k , x , i) ;
y.insert(i) ;
}
}
printf("%ld\n" , y.size()) ;
for (set<int > ::iterator it = y.begin(); it!=y.end() ; it++) {
int x = (*it * k )/(*it - k ) ;
printf("1/%d = 1/%d + 1/%d\n" , k , x, *it) ;
}
}
return 0;
}