#include #include #include #include #define NUM_CCIES 200 using namespace std; struct Rate { long from, to; Rate operator *( const Rate &r) const { Rate ret; ret.from = from * r.from; ret.to = to * r.to; return ret; } bool operator != ( const Rate &r)const { return from * r.to != r.from * to; } bool operator < ( const Rate &r)const { return from * r.to < r.from * to; } }; struct Matrix{ Rate e[NUM_CCIES][NUM_CCIES]; }; int NumCcies; Matrix rates; Matrix product( const Matrix &r1, const Matrix &r2) { Matrix ret; memset(&ret, 0, sizeof(ret)); for ( int i=0; i ccyind; NumCcies=0; scanf("%d", &NumCcies); if (NumCcies==0) break; for ( int i=0; isecond; int ind2=ccyind.find(ccy2)->second; rates.e[ind1][ind2].from=val1; rates.e[ind1][ind2].to=val2; } //print(); if (notfirst) printf("\n"); notfirst=1; int i; for ( i=0; i<9; ++i) { rates = product( rates, rates); // print(); if ( check(rates)) { printf("Arbitrage"); break; } } if ( i==9) printf("Ok"); } return 0; }