結果

問題 No.1126 SUM
ユーザー face4
提出日時 2020-07-25 16:44:30
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 92 ms / 1,000 ms
コード長 538 bytes
コンパイル時間 483 ms
コンパイル使用メモリ 64,000 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-27 08:57:08
合計ジャッジ時間 2,445 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

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