結果
| 問題 |
No.1680 Sum and Difference
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-07-10 00:00:20 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,515 bytes |
| コンパイル時間 | 1,578 ms |
| コンパイル使用メモリ | 161,012 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2025-01-01 18:10:40 |
| 合計ジャッジ時間 | 2,086 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:60:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
60 | scanf("%lld %lld", &A, &B);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9 + 7;
struct mint {
using ull = unsigned long long;
ull a;
constexpr mint(const ull x = 0) noexcept : a(x % MOD) {}
constexpr mint operator+(const mint rhs) const noexcept {
return mint(*this) += rhs;
}
constexpr mint operator-(const mint rhs) const noexcept {
return mint(*this) -= rhs;
}
constexpr mint operator*(const mint rhs) const noexcept {
return mint(*this) *= rhs;
}
constexpr mint operator/(const mint rhs) const noexcept {
return mint(*this) /= rhs;
}
constexpr mint &operator+=(const mint rhs) noexcept {
a += rhs.a;
if (a >= MOD) a -= MOD;
return *this;
}
constexpr mint &operator-=(const mint rhs) noexcept {
if (a < rhs.a)a += MOD;
a -= rhs.a;
return *this;
}
constexpr mint &operator*=(const mint rhs) noexcept {
a = a * rhs.a % MOD;
return *this;
}
constexpr mint &operator/=(mint rhs) noexcept {
ull exp = MOD - 2;
while (exp) {
if (exp % 2) *this *= rhs;
rhs *= rhs;
exp /= 2;
}
return *this;
}
constexpr mint pow(const mint &a, ull n) noexcept {
if (n == 0) return 1;
auto t = pow(a, n / 2);
t = t * t;
if (n & 1) t = t * a;
return t;
}
};
int main(void) {
ll A, B;
scanf("%lld %lld", &A, &B);
mint x = A, y = B;
mint ans = x * y * 2 + x + y + 1;
if (A % 2 == B % 2) printf("%lld\n", ans.a);
else printf("%lld\n", (ans - 1).a);
return 0;
}