結果
| 問題 |
No.916 Encounter On A Tree
|
| コンテスト | |
| ユーザー |
onigawara_kypr
|
| 提出日時 | 2019-10-28 03:20:57 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,854 bytes |
| コンパイル時間 | 1,142 ms |
| コンパイル使用メモリ | 103,724 KB |
| 実行使用メモリ | 11,520 KB |
| 最終ジャッジ日時 | 2024-09-14 21:10:16 |
| 合計ジャッジ時間 | 2,993 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 39 WA * 17 |
ソースコード
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
using namespace std;
using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template<class T> inline bool chmax(T& a, T b) {if (a<b) {a=b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b) {if (a>b) {a=b; return true;} return false;}
const ll MOD = 1000000007;
const ll HIGHINF = (ll)1e18;
ll pow2(ll i) {
if (i==0) return 1;
else {
ll tmp = pow2(i/2);
if (i&1) return ((tmp*tmp)%MOD)*2%MOD;
else return tmp*tmp%MOD;
}
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll d, l, r, k; cin >> d >> l >> r >> k;
ll dl=0, dr=0;
while ((l>>=1)!=0) dl++;
while ((r>>=1)!=0) dr++;
ll lca;
if (dl+dr < k || (k-(dr-dl))%2==1) {
cout << 0 << '\n';
return 0;
} else {
lca = (k-(dr-dl))/2;
}
// cerr << dl << ' ' << dr << ' ' << lca << '\n';
vll fac((1<<d), 1);
rep(i, 1, (1<<d)) fac[i] = fac[i-1]*i%MOD;
ll ans=1;
REP(i, d) {
ll tmp = pow2(i);
if (i==dl) tmp--;
if (i==dr) tmp--;
ans = ans * fac[tmp] % MOD;
}
ans = ans*pow2(dl-lca)%MOD; // lca
ans = ans*pow2(lca)%MOD; // left
ans = ans*pow2(lca+dr-dl-(dr==dl?1:0))%MOD; // right
cout << ans << '\n';
return 0;
}
onigawara_kypr