結果

問題 No.916 Encounter On A Tree
ユーザー season1618season1618
提出日時 2019-10-25 23:18:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,545 bytes
コンパイル時間 1,593 ms
コンパイル使用メモリ 165,308 KB
実行使用メモリ 81,804 KB
最終ジャッジ日時 2023-10-11 09:34:00
合計ジャッジ時間 6,709 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 73 ms
81,588 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 71 ms
81,540 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 72 ms
81,468 KB
testcase_08 AC 71 ms
81,468 KB
testcase_09 AC 72 ms
81,480 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 71 ms
81,468 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 70 ms
81,468 KB
testcase_14 WA -
testcase_15 AC 71 ms
81,460 KB
testcase_16 AC 1 ms
4,348 KB
testcase_17 AC 72 ms
81,668 KB
testcase_18 AC 71 ms
81,524 KB
testcase_19 AC 71 ms
81,532 KB
testcase_20 AC 1 ms
4,348 KB
testcase_21 AC 71 ms
81,468 KB
testcase_22 AC 1 ms
4,352 KB
testcase_23 AC 71 ms
81,540 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 71 ms
81,668 KB
testcase_26 AC 1 ms
4,352 KB
testcase_27 AC 70 ms
81,788 KB
testcase_28 AC 1 ms
4,348 KB
testcase_29 AC 71 ms
81,536 KB
testcase_30 AC 1 ms
4,352 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 71 ms
81,472 KB
testcase_35 AC 71 ms
81,600 KB
testcase_36 AC 71 ms
81,520 KB
testcase_37 AC 70 ms
81,528 KB
testcase_38 AC 71 ms
81,532 KB
testcase_39 WA -
testcase_40 AC 71 ms
81,540 KB
testcase_41 AC 71 ms
81,748 KB
testcase_42 AC 71 ms
81,480 KB
testcase_43 AC 72 ms
81,520 KB
testcase_44 AC 2 ms
4,348 KB
testcase_45 AC 71 ms
81,532 KB
testcase_46 AC 1 ms
4,352 KB
testcase_47 AC 72 ms
81,528 KB
testcase_48 WA -
testcase_49 AC 71 ms
81,540 KB
testcase_50 AC 72 ms
81,520 KB
testcase_51 AC 71 ms
81,468 KB
testcase_52 AC 71 ms
81,540 KB
testcase_53 AC 71 ms
81,664 KB
testcase_54 AC 2 ms
4,348 KB
testcase_55 AC 72 ms
81,596 KB
testcase_56 AC 72 ms
81,472 KB
testcase_57 AC 71 ms
81,468 KB
testcase_58 AC 72 ms
81,528 KB
testcase_59 AC 72 ms
81,536 KB
testcase_60 AC 72 ms
81,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e7;
const int INF=1e9;
int depth(long v){
	int i=0;
	while(v){
		i++;
		v/=2;
	}return i;
}
long calc(int a,int b,long d){
    long fact[size];
    long res=1;fact[0]=1;
    rep(i,1,size){
    	(res*=i)%=mod;
    	fact[i]=res;
    }
    long node=1;long ans=1;
    rep(i,1,d+1){
    	if(i==a&&i==b) (ans*=fact[node-2])%=mod;
    	else if(i==a||i==b) (ans*=fact[node-1])%=mod;
    	else (ans*=fact[node])%=mod;
        node*=2;
    }return ans;
}
long modpow(long x,int n,long p){
	int i=0;long res=1;
	while(n>=(1<<i)){
		if(n&(1<<i)) (res*=x)%=p;
		i++;x=x*x%p;
	}return res;
}
int main(){
	long d,l,r,k;cin>>d>>l>>r>>k;
	int a=depth(l);int b=depth(r);
	if((a+b-k)%2==1||b-a>k){ cout<<0<<endl; return 0; }
	long ans=calc(a,b,d);
	if(b-a==k) (ans*=modpow(2,b-1,mod))%=mod;
	else (ans*=modpow(2,(a+b+k)/2-2,mod))%=mod;
	cout<<ans<<endl;
}
//63 64 68 69 70
/*タスクを並列に行う
x=(x ? true : false)
sorted
auto it=lower_bound(v.begin(),v.end(),w) v[it-v.begin()]>=w
auto it=upper_bound(v.begin(),v.end(),w) v[it-v.begin()]>w
void func(int* vec){}
puts(string) cout<<string<<endl;
1.*a/b int to double
(int)a-48 char to int
(char)(i+97) int to char
stoi(s) string to int
stoll(s)
cout.precision(16);
cout<<fixed<<a;
printf("%.6lf\n",a);
accumulate(a,a+n,0);
*/
0