ICPC Notebook

This documentation is automatically generated by online-judge-tools/verification-helper

View the Project on GitHub tatyam-prime/ICPC_notebook

:heavy_check_mark: test/modint/modint.test.cpp

Depends on

Code

#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A"
#include "test/template.hpp"
#include "src/modint/modint.hpp"

mt19937 rnd(random_device{}());
int main() {
   rep(i, 0, 1e5) {
      const ll a = rnd() % mod, b = rnd() % mod;
      mm A = a, B = b, C = A * B;
      assert((A + B).x == (a + b) % mod);
      assert((A - B).x == (a - b + mod) % mod);
      assert(C.x == (a * b) % mod);
      assert((A / B.inv()).x == C.x);
      A = a;
      assert((A += B).x == (a + b) % mod);
      A = a;
      assert((A -= B).x == (a - b + mod) % mod);
      A = a;
      assert((A *= B).x == (a * b) % mod);
      A = a;
      assert((A /= B.inv()).x == C.x);
   }
   puts("Hello World");
}
#line 1 "test/modint/modint.test.cpp"
#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_A"
#line 1 "test/template.hpp"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX / 4;
#define rep(i, a, b) for(ll i = a; i < (b); i++)
#define all(a) begin(a), end(a)
#define sz(a) ssize(a)
bool chmin(auto& a, auto b) { return a > b ? a = b, 1 : 0; }
bool chmax(auto& a, auto b) { return a < b ? a = b, 1 : 0; }
#line 1 "src/modint/modint.hpp"
const ll mod = 998244353;
struct mm {
   ll x;
   mm(ll x_ = 0) : x(x_ % mod) {
      if(x < 0) x += mod;
   }
   friend mm operator+(mm a, mm b) { return a.x + b.x; }
   friend mm operator-(mm a, mm b) { return a.x - b.x; }
   friend mm operator*(mm a, mm b) { return a.x * b.x; }
   friend mm operator/(mm a, mm b) { return a * b.inv(); }
   // 4 行コピペ  Alt + Shift + クリックで複数カーソル
   friend mm& operator+=(mm& a, mm b) { return a = a.x + b.x; }
   friend mm& operator-=(mm& a, mm b) { return a = a.x - b.x; }
   friend mm& operator*=(mm& a, mm b) { return a = a.x * b.x; }
   friend mm& operator/=(mm& a, mm b) { return a = a * b.inv(); }
   mm inv() const { return pow(mod - 2); }
   mm pow(ll b) const {
      mm a = *this, c = 1;
      while(b) {
         if(b & 1) c *= a;
         a *= a;
         b >>= 1;
      }
      return c;
   }
};
#line 4 "test/modint/modint.test.cpp"

mt19937 rnd(random_device{}());
int main() {
   rep(i, 0, 1e5) {
      const ll a = rnd() % mod, b = rnd() % mod;
      mm A = a, B = b, C = A * B;
      assert((A + B).x == (a + b) % mod);
      assert((A - B).x == (a - b + mod) % mod);
      assert(C.x == (a * b) % mod);
      assert((A / B.inv()).x == C.x);
      A = a;
      assert((A += B).x == (a + b) % mod);
      A = a;
      assert((A -= B).x == (a - b + mod) % mod);
      A = a;
      assert((A *= B).x == (a * b) % mod);
      A = a;
      assert((A /= B.inv()).x == C.x);
   }
   puts("Hello World");
}
Back to top page