uva 10976 - Fractions Again?! Solution
uva 10976 - Fractions Again?! #include<iostream> #include<algorithm> #include<vector> using namespace std; int main(){ unsigned int i, n,m,count; while (cin >> n){ vector<int>vec; m = 2 * n; count = 0; for (i = n+1; i <= m; i++){ if ((n*i)%(i-n) == 0){ count++; vec.push_back((n*i) / (i - n)); vec.push_back(i); } } cout << count << endl; i = 0; while (count--){ cout << "1/" << n << " = 1/" << vec[i++]; cout << " + 1/" << vec[i++] << endl; } } return 0; }