結果
問題 | No.2847 Birthday Attack |
ユーザー | Fu_L |
提出日時 | 2024-08-23 22:24:39 |
言語 | C++23(gcc13) (gcc 13.2.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 4,696 bytes |
コンパイル時間 | 3,450 ms |
コンパイル使用メモリ | 275,840 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-08-23 22:24:45 |
合計ジャッジ時間 | 4,367 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,940 KB |
testcase_03 | AC | 8 ms
6,940 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using P = pair<ll, ll>; #define rep(i, a, b) for(ll i = a; i < b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) constexpr ll inf = 4e18; struct SetupIO { SetupIO() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(30); } } setup_io; struct Barrett { explicit Barrett(unsigned int m) : _m(m), im((unsigned long long)(-1) / m + 1) {} inline unsigned int umod() const { return _m; } inline unsigned int mul(unsigned int a, unsigned int b) const { unsigned long long z = a; z *= b; unsigned long long x = (unsigned long long)(((unsigned __int128)(z)*im) >> 64); unsigned int v = (unsigned int)(z - x * _m); if(_m <= v) v += _m; return v; } private: unsigned int _m; unsigned long long im; }; template <int id> struct DynamicModint { using mint = DynamicModint; static int mod() { return (int)bt.umod(); } static void set_mod(int m) { assert(1 <= m); bt = Barrett(m); } static mint raw(int v) { mint a; a._v = v; return a; } DynamicModint() : _v(0) {} template <class T> DynamicModint(const T& v) { static_assert(is_integral_v<T>); if(is_signed_v<T>) { long long x = (long long)(v % (long long)(umod())); if(x < 0) x += umod(); _v = (unsigned int)(x); } else _v = (unsigned int)(v % umod()); } unsigned int val() const { return _v; } mint& operator++() { ++_v; if(_v == umod()) _v = 0; return *this; } mint& operator--() { if(_v == 0) _v = umod(); --_v; return *this; } mint operator++(int) { mint res = *this; ++*this; return res; } mint operator--(int) { mint res = *this; --*this; return res; } mint& operator+=(const mint& rhs) { _v += rhs._v; if(_v >= umod()) _v -= umod(); return *this; } mint& operator-=(const mint& rhs) { _v += mod() - rhs._v; if(_v >= umod()) _v -= umod(); return *this; } mint& operator*=(const mint& rhs) { _v = bt.mul(_v, rhs._v); return *this; } mint& operator/=(const mint& rhs) { return *this *= rhs.inv(); } mint operator+() const { return *this; } mint operator-() const { return mint() - *this; } mint pow(long long n) const { assert(0 <= n); if(n == 0) return 1; mint x = *this, r = 1; while(1) { if(n & 1) r *= x; n >>= 1; if(n == 0) return r; x *= x; } } mint inv() const { auto eg = inv_gcd(_v, mod()); assert(eg.first == 1); return eg.second; } friend mint operator+(const mint& lhs, const mint& rhs) { return mint(lhs) += rhs; } friend mint operator-(const mint& lhs, const mint& rhs) { return mint(lhs) -= rhs; } friend mint operator*(const mint& lhs, const mint& rhs) { return mint(lhs) *= rhs; } friend mint operator/(const mint& lhs, const mint& rhs) { return mint(lhs) /= rhs; } friend bool operator==(const mint& lhs, const mint& rhs) { return lhs._v == rhs._v; } friend bool operator!=(const mint& lhs, const mint& rhs) { return lhs._v != rhs._v; } friend istream& operator>>(istream& in, mint& x) { long long a; in >> a; x = a; return in; } friend ostream& operator<<(ostream& out, const mint& x) { return out << x.val(); } private: unsigned int _v = 0; static Barrett bt; inline static unsigned int umod() { return bt.umod(); } inline static pair<long long, long long> inv_gcd(long long a, long long b) { if(a == 0) return {b, 0}; long long s = b, t = a, m0 = 0, m1 = 1; while(t) { const long long u = s / t; s -= t * u; m0 -= m1 * u; swap(s, t); swap(m0, m1); } if(m0 < 0) m0 += b / s; return {s, m0}; } }; template <int id> Barrett DynamicModint<id>::bt(998244353); using modint = DynamicModint<-1>; using mint = modint; int main(void) { ll x, y, m; cin >> x >> y >> m; mint::set_mod(m); mint ans = 0; for(ll r = 2; r <= max(x, y); r += 2) { ans += 2 * max(x - r, 0ll) * y + 2 * max(y - r, 0ll) * x; } cout << ans << '\n'; }