From 95a6273bb67a1440dffe06687d62b13e12937abd Mon Sep 17 00:00:00 2001 From: szdytom Date: Mon, 14 Aug 2023 12:37:53 +0800 Subject: [PATCH 1/2] add operator bool to modint Signed-off-by: szdytom --- atcoder/modint.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/atcoder/modint.hpp b/atcoder/modint.hpp index cfcf815..108e2e3 100644 --- a/atcoder/modint.hpp +++ b/atcoder/modint.hpp @@ -91,6 +91,7 @@ struct static_modint : internal::static_modint_base { mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } + operator bool() const { return _v == 0; } mint pow(long long n) const { assert(0 <= n); @@ -206,6 +207,7 @@ template struct dynamic_modint : internal::modint_base { mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } + operator bool() const { return _v == 0; } mint pow(long long n) const { assert(0 <= n); From 7109e282816a6012f20390ae0727fef1f869ff13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E8=80=8C=E9=9D=99?= Date: Fri, 18 Aug 2023 16:27:12 +0800 Subject: [PATCH 2/2] swap true/false in modint operator bool --- atcoder/modint.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/atcoder/modint.hpp b/atcoder/modint.hpp index 108e2e3..618767d 100644 --- a/atcoder/modint.hpp +++ b/atcoder/modint.hpp @@ -91,7 +91,7 @@ struct static_modint : internal::static_modint_base { mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } - operator bool() const { return _v == 0; } + operator bool() const { return _v != 0; } mint pow(long long n) const { assert(0 <= n); @@ -207,7 +207,7 @@ template struct dynamic_modint : internal::modint_base { mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } - operator bool() const { return _v == 0; } + operator bool() const { return _v != 0; } mint pow(long long n) const { assert(0 <= n);