#include #include #include #include #include #include using namespace std; // ModInt begin using ll = long long; template struct ModInt { ll v; ll mod_pow(ll x, ll n) const { return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod; } ModInt(ll a = 0) : v(a >= mod ? a % mod : a) {} ModInt operator+ ( const ModInt& b ) const { return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v)); } ModInt operator- () const { return ModInt(-v); } ModInt operator- ( const ModInt& b ) const { return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v)); } ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;} ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;} bool operator== ( const ModInt &b ) const {return v == b.v;} bool operator!= ( const ModInt &b ) const {return !(*this == b); } ModInt& operator+= ( const ModInt &b ) { v += b.v; if(v >= mod) v -= mod; return *this; } ModInt& operator-= ( const ModInt &b ) { v -= b.v; if(v < 0) v += mod; return *this; } ModInt& operator*= ( const ModInt &b ) { (v *= b.v) %= mod; return *this; } ModInt& operator/= ( const ModInt &b ) { (v *= mod_pow(b.v, mod-2)) %= mod; return *this; } ModInt pow(ll x) { return ModInt(mod_pow(v, x)); } // operator int() const { return int(v); } // operator long long int() const { return v; } }; template ostream& operator<< (ostream& out, ModInt a) {return out << a.v;} template istream& operator>> (istream& in, ModInt& a) { in >> a.v; return in; } // ModInt end // 行列ライブラリ // size(): 行数を返す (列数は mat[0].size() で) // 演算子: 複合代入 (+=, *=, -=), 単項 (-), 二項 (+, -, *, ==) // eigen(N): N*N 単位行列を返す // pow(mat, k): mat の k 乗を返す template struct Matrix { vector< vector > mat; Matrix() {} Matrix(int h, int w, T val = T(0)) : mat(h, vector(w, val)) {} size_t size() const { return mat.size(); } const vector& operator[](int i) const { return mat[i]; } vector& operator[](int i) { return mat[i]; } Matrix &operator+=(const Matrix& rhs) { assert(mat.size() == rhs.size()); assert(mat[0].size() == rhs[0].size()); for(size_t i=0; i operator-() const { Matrix res(*this); for(size_t i=0; i operator-=(const Matrix& rhs) { return (Matrix(*this) += -rhs); } Matrix& operator*=(const Matrix& rhs) { assert(mat[0].size() == rhs.size()); size_t H = mat.size(), W = rhs[0].size(), C = rhs.size(); Matrix res(H, W); for(size_t i=0; imat = res.mat; return *this; } Matrix operator+(const Matrix& rhs) { return (Matrix(*this) += rhs); } Matrix operator*(const Matrix& rhs) { return (Matrix(*this) *= rhs); } Matrix operator-(const Matrix &rhs) { return (Matrix(*this) -= rhs); } bool operator==(const Matrix &rhs) const { return this->mat == rhs.mat; } bool operator!=(const Matrix &rhs) const { return !(*this == rhs); } }; template Matrix eigen(size_t N) { Matrix res(N, N, 0); for(size_t i=0; i Matrix pow(Matrix mat, long long int k) { Matrix res = eigen(mat.size()); for(; k>0; k>>=1) { if(k & 1) res *= mat; mat *= mat; } return res; } template ostream& operator<< (ostream& out, Matrix mat) { int H = mat.size(), W = mat[0].size(); out << "[" << endl; for(int i=0; i int gaussianEliminationModp(Matrix &mat, bool ext=false) { int N = mat.size(), M = mat[0].size(), rank = 0; for(int j=0; j+ext vector linearEquationModp(Matrix A, vector b) { int N = A.size(), M = A[0].size(); Matrix mat(N, M+1); for(int i=0; i res(N); for(int i=0; i= rank and mat[i][M] == mint(0)) return {}; } return res; } template mint detModp(Matrix A) { int N = A.size(), cnt_swap = 0; for(int j=0; j; int N; cin >> N; Matrix mat(N, N); for(int i=0; i> c; if(c == '1') mat[i][j] = mint(1); } } mint d = detModp(mat); if(d == mint(0)) cout << "Even" << endl; else cout << "Odd" << endl; } void yuki_803() { using mint = ModInt<2>; const int B = 30; int N, M, X; cin >> N >> M >> X; Matrix mat(B+M, N+1); for(int j=0; j>= 1; } for(int i=0; i> val; for(int j=0; j>= 1; } } for(int i=0; i> t >> l >> r; l--; mat[B+i][N] = t; for(int x=l; x(2).pow(p) << endl; } int main() { // ARC054_C(); // detModp yuki_803(); // gaussianEliminationModp }