#include // #include #include "operators_new.hpp" int cnt = 0; template< class T, size_t N > class BigMatrixSimulator : boost::operators< BigMatrixSimulator< T, N > > { private: T values_[N]; public: explicit BigMatrixSimulator( T value ) { ++cnt; for( size_t i = 0; i < N; ++i ) values_[i] = value; } BigMatrixSimulator( const BigMatrixSimulator& rhs ) { +cnt; for( size_t i = 0; i < N; ++i ) values_[i] = rhs.values_[i]; } BigMatrixSimulator& operator=( const BigMatrixSimulator& rhs ) { for( size_t i = 0; i < N; ++i ) values_[i] = rhs.values_[i]; return *this; } #define ADD_OPERATOR( OP ) \ BigMatrixSimulator& operator OP(const BigMatrixSimulator& x) { \ for( size_t i = 0; i < N; ++i ) \ values_[i] OP x.values_[i]; \ return *this; \ } ADD_OPERATOR( += ); ADD_OPERATOR( -= ); ADD_OPERATOR( *= ); ADD_OPERATOR( /= ); ADD_OPERATOR( %= ); ADD_OPERATOR( |= ); ADD_OPERATOR( &= ); ADD_OPERATOR( ^= ); }; int main() { typedef BigMatrixSimulator< int, 100000 > X; X one( 1 ); X max( 65535 ); X x1( 1 ); X x2( 2 ); X x3( 3 ); for( int i = 0; i < 10; ++i ) { X t1 = ( ( x1*x2 + x3 ) | one ) & max; X t2 = ( ( x2*x3 + x1 ) | one ) & max; X t3 = ( ( x1*x3 + x2 ) | one ) & max; X d = ( ( x1 / x2 + x2 / x3 + x3 / x1 ) | one ) & max; x1 = t1 - t2 / d; x2 = t1 - t3 / d; x3 = t2 - t3 / d; d = ( ( t1 & x1 ) | ( t2 & x2 ) | ( t3 | x3 ) ) | ( x1 ^ x2 ^ x3 ); X t = x1; x1 = x2 % d; x2 = x3 % d; x3 = t % d; } std::cout << ( cnt - 5 ) / 10 << std::endl; }