#include #include #include #include #include #include #include #include #include #include using namespace std; //#define __int64 long long #define long __int64 #define REP(i,a,b) for(int i=a;i> t[i]; tes[i] = t[i]; } //最小公倍数を求める check = 2; while(check <= max(tes[0], max(tes[1],tes[2]))){ cnt = 0; for(int i=0; i<3; i++){ if(tes[i] % check == 0){ test[i] = true; cnt ++; }else{ test[i] = false; } } if(cnt >= 2){ sudare[cnt_s] = check; cnt_s ++; for(int i=0; i<3; i++){ if(test[i]){ tes[i] /= check; } } }else{ check ++; } } for(int i=0; i=1; i--){ for(int ii=0; ii<3; ii++){ loc[ii] = (ans1 / (double)i) / t[ii]; loc[ii] = loc[ii] - floor(loc[ii]); } flg = true; check_loc = loc[0]; for(int ii=1; ii<3; ii++){ /* if(i == 18){ cout << loc[ii] << "+" << check_loc << " == 1" << endl; cout << loc[ii] << " == " << check_loc << endl; cout << (loc[ii] + check_loc == 1) << endl; } */ check1 = loc[ii] + check_loc; check2 = loc[ii] - check_loc; if(!((check1 >= 0.9999 && check1 <= 1.0001) || (check2 >= -0.0001 && check2 <= 0.0001))){ //cout << "out"; flg = false; break; }else{ //cout << "safe"; } } if(flg){ ans2 = i; break; } } //最大公約数を求める c1 = ans1; c2 = ans2; int amari; while(c2 != 0){ amari = c1 % c2; c1 = c2; c2 = amari; } if(c1 != 1){ ans1 /= c1; ans2 /= c1; } cout << ans1 << "/" << ans2; return 0; }