結果

問題 No.1126 SUM
ユーザー face4face4
提出日時 2020-07-25 16:44:30
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 1,000 ms
コード長 538 bytes
コンパイル時間 456 ms
コンパイル使用メモリ 64,260 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-09 16:09:58
合計ジャッジ時間 2,817 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
4,380 KB
testcase_01 AC 40 ms
4,376 KB
testcase_02 AC 24 ms
4,376 KB
testcase_03 AC 7 ms
4,380 KB
testcase_04 AC 38 ms
4,380 KB
testcase_05 AC 36 ms
4,376 KB
testcase_06 AC 29 ms
4,376 KB
testcase_07 AC 63 ms
4,380 KB
testcase_08 AC 57 ms
4,376 KB
testcase_09 AC 52 ms
4,376 KB
testcase_10 AC 10 ms
4,376 KB
testcase_11 AC 59 ms
4,376 KB
testcase_12 AC 73 ms
4,376 KB
testcase_13 AC 39 ms
4,376 KB
testcase_14 AC 14 ms
4,380 KB
testcase_15 AC 13 ms
4,376 KB
testcase_16 AC 55 ms
4,380 KB
testcase_17 AC 23 ms
4,380 KB
testcase_18 AC 52 ms
4,376 KB
testcase_19 AC 30 ms
4,376 KB
testcase_20 AC 29 ms
4,380 KB
testcase_21 AC 29 ms
4,380 KB
testcase_22 AC 28 ms
4,376 KB
testcase_23 AC 49 ms
4,380 KB
testcase_24 AC 53 ms
4,380 KB
testcase_25 AC 96 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
typedef long long ll;

ll modpow(ll a, ll b, ll p = 1e9+7){
    if(b == 0)  return 1;

    if(b % 2 == 0){
        ll d = modpow(a, b/2, p);
        return (d*d) % p;
    }else{
        return (a%p * modpow(a, b-1, p)) % p;
    }
}

const ll mod = 1000000007;

int main(){
    int n, m;
    cin >> n >> m;
    ll tmp = 1, ans = 0;
    for(int i = n; i <= m; i++){
        ans = (ans+tmp)%mod;
        tmp = tmp*modpow(i-n+1, mod-2, mod)%mod*(i+1)%mod;
    }
    cout << ans << endl;
    return 0;
}
0