// #includes {{{ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; // }}} // pre-written code {{{ #define REP(i,n) for(int i=0;i<(int)(n);++i) #define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i) #define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i) #define LET(x,a) __typeof(a) x(a) //#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i) #define ALL(c) (c).begin(), (c).end() #define MP make_pair #define EXIST(e,s) ((s).find(e)!=(s).end()) #define RESET(a) memset((a),0,sizeof(a)) #define SET(a) memset((a),-1,sizeof(a)) #define PB push_back #define DEC(it,command) __typeof(command) it=command //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; #define debug2(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl; const int INF=0x3f3f3f3f; typedef long long Int; typedef unsigned long long uInt; #ifdef __MINGW32__ typedef double rn; #else typedef long double rn; #endif typedef pair pii; /* #ifdef MYDEBUG #include"debug.h" #include"print.h" #endif */ // }}} int N; vector t[3]; rn EPS=1e-14L; vector listed; int main(){ cin>>N; REP(i,3)t[i].push_back(1.0L); listed.push_back(1.0L); REP(i,N){ int p,a,b; cin>>p>>a>>b; t[p].push_back((rn)a/(rn)(a+b)); if(p==2)listed.push_back(t[p].back()); } sort(ALL(listed)); Int d = 0; REP(i,t[0].size())REP(j,t[1].size()){ rn u = 2.0L-(t[0][i] + t[1][j]); d+=distance(lower_bound(ALL(listed),u-EPS),upper_bound(ALL(listed),u+EPS)); } Int ans = 0; REP(i,t[0].size())REP(j,t[1].size()){ if(t[0][i]+t[1][j]<1.0L-EPS)continue; rn u = max(1.0L-t[0][i],1.0L-t[1][j]); Int k = distance(lower_bound(ALL(listed),u-EPS),listed.end()); // cout<