結果
| 問題 |
No.916 Encounter On A Tree
|
| コンテスト | |
| ユーザー |
auaua
|
| 提出日時 | 2019-10-25 22:56:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,071 bytes |
| コンパイル時間 | 1,313 ms |
| コンパイル使用メモリ | 160,312 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-13 06:39:31 |
| 合計ジャッジ時間 | 2,957 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 2 |
| other | AC * 10 WA * 46 |
ソースコード
#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;
ll anc=(depth(l)+depth(r)-k)/2;
ans*=e(depth(l)-anc-1);
ans%=inf;
ans*=e(depth(r)-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(i==depth(r)-1)k--;
else if(i==depth(l)-1)k--;
while(k>1){
ans*=k;
ans%=inf;
k--;
}
}
cout<<ans<<endl;
}
auaua