結果

問題 No.916 Encounter On A Tree
ユーザー kotatsugamekotatsugame
提出日時 2019-10-25 22:43:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 65,152 KB
実行使用メモリ 11,796 KB
最終ジャッジ日時 2023-10-11 07:02:42
合計ジャッジ時間 3,928 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
11,456 KB
testcase_01 AC 22 ms
11,452 KB
testcase_02 AC 23 ms
11,580 KB
testcase_03 AC 22 ms
11,580 KB
testcase_04 AC 22 ms
11,460 KB
testcase_05 AC 22 ms
11,508 KB
testcase_06 AC 22 ms
11,544 KB
testcase_07 AC 22 ms
11,644 KB
testcase_08 AC 22 ms
11,724 KB
testcase_09 AC 22 ms
11,468 KB
testcase_10 AC 22 ms
11,584 KB
testcase_11 AC 22 ms
11,504 KB
testcase_12 AC 21 ms
11,668 KB
testcase_13 AC 21 ms
11,588 KB
testcase_14 AC 22 ms
11,544 KB
testcase_15 AC 22 ms
11,580 KB
testcase_16 AC 21 ms
11,588 KB
testcase_17 AC 21 ms
11,524 KB
testcase_18 AC 22 ms
11,576 KB
testcase_19 AC 22 ms
11,576 KB
testcase_20 AC 22 ms
11,644 KB
testcase_21 AC 22 ms
11,452 KB
testcase_22 AC 21 ms
11,448 KB
testcase_23 AC 22 ms
11,524 KB
testcase_24 AC 22 ms
11,696 KB
testcase_25 AC 21 ms
11,792 KB
testcase_26 AC 21 ms
11,532 KB
testcase_27 AC 22 ms
11,576 KB
testcase_28 AC 22 ms
11,464 KB
testcase_29 AC 22 ms
11,652 KB
testcase_30 AC 21 ms
11,616 KB
testcase_31 AC 21 ms
11,508 KB
testcase_32 AC 22 ms
11,704 KB
testcase_33 AC 22 ms
11,508 KB
testcase_34 AC 22 ms
11,580 KB
testcase_35 AC 22 ms
11,588 KB
testcase_36 AC 22 ms
11,588 KB
testcase_37 AC 22 ms
11,576 KB
testcase_38 AC 22 ms
11,512 KB
testcase_39 AC 22 ms
11,584 KB
testcase_40 AC 22 ms
11,580 KB
testcase_41 AC 22 ms
11,580 KB
testcase_42 AC 22 ms
11,456 KB
testcase_43 AC 22 ms
11,580 KB
testcase_44 AC 22 ms
11,548 KB
testcase_45 AC 21 ms
11,512 KB
testcase_46 AC 22 ms
11,584 KB
testcase_47 AC 22 ms
11,432 KB
testcase_48 AC 21 ms
11,512 KB
testcase_49 AC 22 ms
11,652 KB
testcase_50 AC 22 ms
11,456 KB
testcase_51 AC 22 ms
11,796 KB
testcase_52 AC 22 ms
11,508 KB
testcase_53 AC 22 ms
11,452 KB
testcase_54 AC 22 ms
11,700 KB
testcase_55 AC 22 ms
11,652 KB
testcase_56 AC 22 ms
11,524 KB
testcase_57 AC 22 ms
11,588 KB
testcase_58 AC 22 ms
11,576 KB
testcase_59 AC 22 ms
11,580 KB
testcase_60 AC 21 ms
11,528 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
using namespace std;
long mod=1e9+7;
long F[(1<<20)+1];
int d,l,r,k;
long power(long a,long b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}
main()
{
	F[0]=1;
	for(long i=1;i<=1<<20;i++)F[i]=F[i-1]*i%mod;
	cin>>d>>l>>r>>k;
	long ans=1;
	for(int i=0;i<d;i++)ans=ans*F[1<<i]%mod;
	int cl=0,cr=0;
	while(l>=1<<cl)cl++;
	while(r>=1<<cr)cr++;
	int diff=cr-cl;
	if(k<diff||k-diff&1)
	{
		cout<<0<<endl;
		return 0;
	}
	k-=diff;
	long out=1LL<<diff;
	if(k==0)
	{
		ans=ans*power(1<<cr-1,mod-2)%mod*out%mod;
	}
	else
	{
		k/=2;
		if(cl<=k)
		{
			cout<<0<<endl;
			return 0;
		}
		out<<=k;
		if(cl<cr)
		{
			ans=ans*power(1<<cr,mod-2)%mod*out%mod;
		}
		else
		{
			ans=ans*power((1<<cr-1)-1,mod-2)%mod*(out/2)%mod;
		}
	}
	cout<<ans<<endl;
}
0