結果

問題 No.1680 Sum and Difference
ユーザー ぷら
提出日時 2021-09-17 22:07:32
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 440 bytes
コンパイル時間 2,199 ms
コンパイル使用メモリ 193,260 KB
最終ジャッジ日時 2025-01-24 15:00:33
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

constexpr int mod = 1000000007;

int main() {
    long long A,B;
    cin >> A >> B;
    long long ans = A/2*2+1;
    ans %= mod;
    ans += (A*4+2)%mod*((B/2)%mod)%mod;
    ans %= mod;
    if(B%2 == 1) {
        if(A%2 == 0) {
            ans += A*2;
            ans %= mod;
        }
        else {
            ans += A*2+2;
            ans %= mod;
        }
    }
    cout << ans << endl;
}
0