結果

問題 No.916 Encounter On A Tree
ユーザー tempura_pptempura_pp
提出日時 2019-03-19 02:49:07
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 61 ms / 2,000 ms
コード長 1,720 bytes
コンパイル時間 972 ms
コンパイル使用メモリ 99,980 KB
実行使用メモリ 27,808 KB
最終ジャッジ日時 2023-10-19 04:39:30
合計ジャッジ時間 4,655 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 55 ms
27,808 KB
testcase_03 AC 53 ms
27,808 KB
testcase_04 AC 61 ms
27,808 KB
testcase_05 AC 58 ms
27,808 KB
testcase_06 AC 53 ms
27,808 KB
testcase_07 AC 56 ms
27,808 KB
testcase_08 AC 8 ms
6,508 KB
testcase_09 AC 13 ms
9,412 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 54 ms
27,808 KB
testcase_13 AC 55 ms
27,808 KB
testcase_14 AC 55 ms
27,808 KB
testcase_15 AC 53 ms
27,808 KB
testcase_16 AC 13 ms
9,412 KB
testcase_17 AC 52 ms
27,808 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 56 ms
27,808 KB
testcase_20 AC 52 ms
27,808 KB
testcase_21 AC 52 ms
27,808 KB
testcase_22 AC 55 ms
27,808 KB
testcase_23 AC 55 ms
27,808 KB
testcase_24 AC 56 ms
27,808 KB
testcase_25 AC 55 ms
27,808 KB
testcase_26 AC 23 ms
15,544 KB
testcase_27 AC 24 ms
15,544 KB
testcase_28 AC 13 ms
9,412 KB
testcase_29 AC 54 ms
27,808 KB
testcase_30 AC 55 ms
27,808 KB
testcase_31 AC 59 ms
27,808 KB
testcase_32 AC 55 ms
27,808 KB
testcase_33 AC 25 ms
15,544 KB
testcase_34 AC 13 ms
9,412 KB
testcase_35 AC 7 ms
6,508 KB
testcase_36 AC 53 ms
27,808 KB
testcase_37 AC 53 ms
27,808 KB
testcase_38 AC 13 ms
9,412 KB
testcase_39 AC 57 ms
27,808 KB
testcase_40 AC 52 ms
27,808 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 2 ms
4,348 KB
testcase_43 AC 2 ms
4,348 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 7 ms
6,508 KB
testcase_46 AC 2 ms
4,348 KB
testcase_47 AC 2 ms
4,348 KB
testcase_48 AC 2 ms
4,348 KB
testcase_49 AC 2 ms
4,348 KB
testcase_50 AC 2 ms
4,348 KB
testcase_51 AC 2 ms
4,348 KB
testcase_52 AC 2 ms
4,348 KB
testcase_53 AC 2 ms
4,348 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 2 ms
4,348 KB
testcase_56 AC 2 ms
4,348 KB
testcase_57 AC 2 ms
4,348 KB
testcase_58 AC 2 ms
4,348 KB
testcase_59 AC 2 ms
4,348 KB
testcase_60 AC 4 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

vector<ll> inv,fact,invfact;
void mod_build(int n=101010){
    fact.resize(n+1);
    inv.resize(n+1);
    invfact.resize(n+1);
    fact[0]=inv[0]=invfact[0]=1;
    inv[1]=1;
    rep(i,n){
        fact[i+1]=fact[i]*(i+1)%mod;
        if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
        invfact[i+1]=invfact[i]*inv[i+1]%mod;
    }
}
ll perm(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
    if(n<0||k<0||k>n)return 0;
    return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
    ll ret=1;
    while(k){
        if(k&1)ret=ret*n%mod;
        n=n*n%mod;
        k>>=1;
    }
    return ret;
}
int main(){
    int d,l,r,k;
    cin>>d>>l>>r>>k;
    int n=1<<d;
    mod_build(n+5);
    int d1=0,d2=0;
    while(l>1){
        ++d1;
        l/=2;
    }
    while(r>1){
        ++d2;
        r/=2;
    }
    int res=d1+d2-k;
    if(res%2||res<0||res/2>d1){
        cout<<0<<endl;
        return 0;
    }
    res/=2;
    ll ret=powmod(2,d2-res-1);
    rep(i,d)(ret*=fact[1<<i])%=mod;
    if(d1!=d2)ret*=inv[1<<d2];
    else ret*=inv[(1<<d2)-1];
    if(res==d1)ret*=2;
    cout<<ret%mod<<endl;
    return 0;
}
0