Uva 10975 Fractions Again?
- // Uva 10976 Fractions Again?
- #include <iostream>
- using namespace std;
- int main()
- {
- int iNumX, iNumY, iNumK;
- int i,j,iCount;
- while ( cin >> iNumK )
- {
- iCount = 0;
- for ( i=iNumK+1 ; i<=2*iNumK ; i++ ) // posibilities of y
- if ( (i*iNumK)%(i-iNumK) == 0 )
- iCount++;
- cout << iCount <<endl;
- for ( i=iNumK+1 ; i<=2*iNumK ; i++ ) // posibilities of y
- if ( (i*iNumK)%(i-iNumK) == 0 )
- cout << "1/" << iNumK << " = " << "1/" << (i*iNumK)/(i-iNumK) << " + " << "1/" << i << endl;
- }
- }
hint:
1/x = 1/k - 1/y
=> 1/x = y-k / k*y
留言
張貼留言