結果

問題 No.916 Encounter On A Tree
ユーザー auauaauaua
提出日時 2019-10-25 23:09:45
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,206 bytes
コンパイル時間 3,374 ms
コンパイル使用メモリ 146,156 KB
実行使用メモリ 4,496 KB
最終ジャッジ日時 2023-10-11 08:16:34
合計ジャッジ時間 5,681 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,368 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 3 ms
4,368 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,372 KB
testcase_12 AC 1 ms
4,368 KB
testcase_13 AC 8 ms
4,368 KB
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 7 ms
4,368 KB
testcase_16 AC 2 ms
4,368 KB
testcase_17 AC 7 ms
4,368 KB
testcase_18 AC 2 ms
4,368 KB
testcase_19 AC 7 ms
4,368 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 2 ms
4,368 KB
testcase_23 WA -
testcase_24 AC 1 ms
4,368 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,368 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,368 KB
testcase_29 WA -
testcase_30 AC 2 ms
4,368 KB
testcase_31 AC 2 ms
4,368 KB
testcase_32 AC 2 ms
4,368 KB
testcase_33 AC 2 ms
4,372 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 7 ms
4,368 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
4,368 KB
testcase_40 AC 7 ms
4,368 KB
testcase_41 AC 1 ms
4,368 KB
testcase_42 AC 2 ms
4,368 KB
testcase_43 AC 1 ms
4,372 KB
testcase_44 AC 2 ms
4,368 KB
testcase_45 WA -
testcase_46 AC 2 ms
4,368 KB
testcase_47 AC 1 ms
4,368 KB
testcase_48 AC 1 ms
4,368 KB
testcase_49 AC 2 ms
4,372 KB
testcase_50 WA -
testcase_51 AC 1 ms
4,372 KB
testcase_52 WA -
testcase_53 AC 2 ms
4,372 KB
testcase_54 AC 2 ms
4,372 KB
testcase_55 WA -
testcase_56 AC 2 ms
4,372 KB
testcase_57 WA -
testcase_58 AC 1 ms
4,372 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll depth(ll a){
    ll cnt=0;
    while(a){
        cnt++;
        a/=2;
    }
    return cnt;
}
ll e(ll d){
    ll res=1;
    ll s=d;
    while(s>0){
        s--;
        res*=2;
        res%=inf;
    }
    return  res;
}
int main(){
    ll d,l,r,k;cin>>d>>l>>r>>k;
    ll ans=1;
    if((depth(l)+depth(r)-k)%2||depth(l)+depth(r)-k<=0){
        cout<<0<<endl;
        return 0;
    }
    ll anc=(depth(l)+depth(r)-k)/2;
    ans*=e(depth(r)-anc-1);
    ans%=inf;
    if(depth(l)>anc)ans*=e(depth(l)-anc-1);
    ans%=inf;
    ans*=2;
    ans%=inf;
    ll f=0;
    if(depth(r)==depth(l))f=1;
    rep(i,d){
        k=e(i);
        if(f&&i==depth(r)-1)k-=2;
        else if(depth(l)!=anc&&i==depth(l)-1)k--;
        else if(i==depth(r)-1)k--;
        while(k>1){
            ans*=k;
            ans%=inf;
            k--;
        }
    }
    cout<<ans<<endl;
}
0