結果

問題 No.1680 Sum and Difference
ユーザー mtrh
提出日時 2021-09-17 22:17:48
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 1,309 ms
コンパイル使用メモリ 166,264 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-29 20:54:16
合計ジャッジ時間 1,957 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 4 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ll A,B;
    cin>>A>>B;
    ll mod=1e9+7;
    if(A%2==0){
        ll ans=A+1;
        ll t=(B/2)%mod;
        t*=A;
        t%=mod;
        t*=2;
        t%=mod;
        ans=(ans+t+10*mod)%mod;
        t=(B/2)%mod;
        t*=(A+1);
        t%=mod;
        t*=2;
        ans=(ans+t+10*mod)%mod;
        if(B%2==1){
            ans+=2*A;
            ans=(ans+10*mod)%mod;
        }
        cout<<ans<<endl;
    }else{
        ll ans=A;
        ll t=(B/2)%mod;
        t*=A;
        t%=mod;
        t*=2;
        t%=mod;
        ans=(ans+t+10*mod)%mod;
        t=(B/2)%mod;
        t*=(A+1);
        t%=mod;
        t*=2;
        ans=(ans+t+10*mod)%mod;
        if(B%2==1){
            ans+=2*(A+1);
            ans=(10*mod+ans)%mod;
        }
        cout<<ans<<endl;
    }
    return 0;
}
0