結果

問題 No.72 そろばん Med
ユーザー face4face4
提出日時 2018-04-30 18:40:38
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 374 bytes
コンパイル時間 567 ms
コンパイル使用メモリ 63,232 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-21 12:11:45
合計ジャッジ時間 1,497 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;

typedef long long ll;

int main(){
    ll n;
    ll ans;
    ll mod = 1000007;

    cin >> n;
    n += 2;

    ll A = (n/2)%mod;
    ll B = (n/2 + 1)%mod;
        
    if(n % 2 == 1){
        ans = (A*B)%mod - 1;
    }else{
        ans = (A*A)%mod - 1;
    }

    if(ans < 0) ans += mod;
    
    cout << ans << endl;
    return 0;
}
0