結果

問題 No.916 Encounter On A Tree
ユーザー pockyny
提出日時 2019-10-25 23:32:16
言語 C++17(1z)
(gcc 8.3.0)
結果
WA   .
実行時間 -
コード長 893 Byte
コンパイル時間 469 ms
使用メモリ 9,700 KB
最終ジャッジ日時 2019-10-25 23:32:19

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
corner1 AC 28 ms
9,692 KB
corner2 AC 2 ms
1,500 KB
corner3 AC 4 ms
1,504 KB
corner4 WA -
corner5 AC 2 ms
1,500 KB
corner6 WA -
corner7 AC 29 ms
9,696 KB
corner8 WA -
corner9 WA -
corner10 WA -
corner11 AC 2 ms
1,500 KB
corner12 WA -
corner13 AC 4 ms
1,500 KB
corner14 WA -
corner15 AC 4 ms
1,500 KB
corner16 WA -
corner17 AC 2 ms
1,504 KB
corner18 WA -
corner19 WA -
corner20 WA -
corner21 AC 29 ms
9,692 KB
large1 WA -
large2 AC 3 ms
1,504 KB
large3 WA -
large4 AC 3 ms
1,504 KB
large5 WA -
large6 AC 4 ms
1,500 KB
large7 WA -
large8 AC 4 ms
1,500 KB
large9 WA -
large10 AC 3 ms
1,500 KB
large11 AC 3 ms
1,500 KB
large12 AC 3 ms
1,504 KB
large13 AC 4 ms
1,504 KB
large14 WA -
large15 WA -
large16 WA -
large17 WA -
large18 WA -
large19 AC 3 ms
1,500 KB
large20 WA -
sample1 WA -
sample2 WA -
sample3 WA -
sample4 AC 4 ms
1,504 KB
sample5 WA -
small1 AC 3 ms
1,504 KB
small2 WA -
small3 AC 3 ms
1,504 KB
small4 WA -
small5 WA -
small6 WA -
small7 WA -
small8 WA -
small9 AC 4 ms
1,500 KB
small10 WA -
small11 WA -
small12 WA -
small13 WA -
small14 WA -
small15 WA -
テストケース一括ダウンロード

ソースコード

diff #
#include <iostream>

using namespace std;
int dig(int x){
	int d = 0;
	while(x){
		x /= 2;
		d++;
	}
	return d;
}
long long mod = 1000000007,f[1<<21];
void solve(){
	f[0] = 1;
	int i;
	for(i=1;i<(1<<20);i++){
		f[i] = i*f[i - 1]%mod;
	}
}

int main(){
	int i,d,l,r,k;
	cin >> d >> l >> r >> k;
	int d1 = dig(l),d2 = dig(r);
	if(d1 + d2 - k<=0 || (d1 + d2 - k)&1){
		cout << 0 << endl;
		return 0;
	}
	solve();
	int dep = (d1 + d2 - k)/2;
	if(dep>d1 || dep>d2){
		cout << 0 << endl;
		return 0;
	}
	long long ans = 1;
	for(i=1;i<=d;i++){
		if(i!=d2){
			(ans *= f[1<<(i - 1)]) %= mod;
		}
	}
	cout << d1 << " " << d2 << " " << k << endl;
	int d3 = d2 - dep;
	if(dep!=d1) d3--;
	if(d1==d2){
		(ans *= (1<<(d2 - 1))) %= mod;
		(ans *= f[(1<<(d2 - 1)) - 2]) %= mod;
		(ans *= (1<<(d3))) %= mod;
	}else{
		(ans *= f[(1<<(d2 - 1)) - 1]) %=mod;
		(ans *= (1<<(d3))) %= mod;
	}
	cout << ans << endl;
}
0