結果

問題 No.834 Random Walk Trip
ユーザー chocoruskchocorusk
提出日時 2019-05-24 23:20:01
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,172 bytes
コンパイル時間 939 ms
コンパイル使用メモリ 99,468 KB
実行使用メモリ 22,724 KB
最終ジャッジ日時 2023-10-17 14:45:35
合計ジャッジ時間 1,938 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 2 ms
5,672 KB
testcase_05 AC 2 ms
5,672 KB
testcase_06 AC 2 ms
5,672 KB
testcase_07 AC 2 ms
5,672 KB
testcase_08 AC 2 ms
5,672 KB
testcase_09 AC 2 ms
5,672 KB
testcase_10 AC 2 ms
5,672 KB
testcase_11 WA -
testcase_12 AC 2 ms
5,672 KB
testcase_13 WA -
testcase_14 AC 2 ms
5,672 KB
testcase_15 AC 2 ms
5,672 KB
testcase_16 AC 3 ms
5,740 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 17 ms
18,628 KB
testcase_24 WA -
testcase_25 AC 21 ms
22,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
	return powmod(a, MOD-2);
}
ll f[1500001], invf[1500001];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(x<y) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
    int n, m; cin>>n>>m;
    fac(m);
     ll ans=0;
    for(int i=(m-1)/2%n; i<=m; i+=n){
        ans+=comb(m, i);
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}
0