#include #include using namespace std; long GCD( long a, long b) { while( b != 0 ) { long temp = b; b = a % b; a = temp; } return a; } void printMinFraction( long numerator, long denominator) { if( numerator == denominator) { cout<< "1"; } else { long commonFactor = GCD( numerator, denominator); cout<< numerator/commonFactor<< "/"<< denominator/commonFactor; } } long taxiPoints( long taxi ) { //using n*(n+1)/2, and 4 quadrents, so reducing the 2 factor return 1+2*taxi*(taxi+1); } long spideyPoints( long spidey ) { long quadrant = spidey*(spidey+1)/2; for(long i = spidey-2; i>0; i-=3) { quadrant += i; } return 1+4*quadrant; } void calculateAndPrintRatio( long taxi, long spidey) { if( spidey >= taxi ) { //entire taxi area is inside spidey area printMinFraction( taxiPoints(taxi), spideyPoints(spidey) ); } else if( taxi >= floor(4*spidey/3) ) { //entire spidey area is inside taxi area cout<< "1\n"; } else { //part of the taxi area is outside the spidey area, and vice versa // Calculating for a single quadrent. Will multiply by 4 and add the origin at distance 0 long taxiPointsInSpideyArea = 0; // add in points in triangle area of spidey distance taxiPointsInSpideyArea += spidey*(spidey+1)/2; //Additionally calculate the points in the spidey arc that are in the taxi distance. for(long i = spidey-2; i> 3*(floor(spidey/3)-(taxi-spidey)); i-=3) { taxiPointsInSpideyArea += i; } printMinFraction( 1 + 4*taxiPointsInSpideyArea, spideyPoints(spidey) ); } } int main() { long taxi, spidey; cin>> taxi>> spidey; calculateAndPrintRatio( taxi, spidey); cout<< endl; return 0; }