結果
問題 | No.916 Encounter On A Tree |
ユーザー | theory_and_me |
提出日時 | 2019-10-26 01:48:19 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 2,229 bytes |
コンパイル時間 | 1,601 ms |
コンパイル使用メモリ | 166,680 KB |
実行使用メモリ | 19,328 KB |
最終ジャッジ日時 | 2024-09-13 13:04:53 |
合計ジャッジ時間 | 4,055 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 15 ms
19,308 KB |
testcase_01 | AC | 15 ms
19,220 KB |
testcase_02 | AC | 15 ms
19,096 KB |
testcase_03 | AC | 15 ms
19,296 KB |
testcase_04 | AC | 15 ms
19,220 KB |
testcase_05 | AC | 16 ms
19,096 KB |
testcase_06 | AC | 16 ms
19,200 KB |
testcase_07 | AC | 16 ms
19,192 KB |
testcase_08 | AC | 15 ms
19,088 KB |
testcase_09 | AC | 15 ms
19,276 KB |
testcase_10 | AC | 16 ms
19,220 KB |
testcase_11 | AC | 15 ms
19,104 KB |
testcase_12 | AC | 15 ms
19,200 KB |
testcase_13 | AC | 18 ms
19,224 KB |
testcase_14 | AC | 16 ms
19,144 KB |
testcase_15 | AC | 16 ms
19,300 KB |
testcase_16 | AC | 16 ms
19,156 KB |
testcase_17 | AC | 15 ms
19,316 KB |
testcase_18 | AC | 15 ms
19,088 KB |
testcase_19 | AC | 15 ms
19,244 KB |
testcase_20 | AC | 15 ms
19,200 KB |
testcase_21 | AC | 15 ms
19,140 KB |
testcase_22 | AC | 15 ms
19,308 KB |
testcase_23 | AC | 15 ms
19,248 KB |
testcase_24 | AC | 16 ms
19,124 KB |
testcase_25 | AC | 16 ms
19,200 KB |
testcase_26 | AC | 15 ms
19,112 KB |
testcase_27 | AC | 15 ms
19,108 KB |
testcase_28 | AC | 15 ms
18,980 KB |
testcase_29 | AC | 16 ms
19,084 KB |
testcase_30 | AC | 16 ms
19,184 KB |
testcase_31 | AC | 15 ms
19,096 KB |
testcase_32 | AC | 15 ms
19,204 KB |
testcase_33 | AC | 17 ms
19,124 KB |
testcase_34 | AC | 15 ms
19,124 KB |
testcase_35 | AC | 15 ms
19,220 KB |
testcase_36 | AC | 15 ms
19,328 KB |
testcase_37 | AC | 15 ms
19,180 KB |
testcase_38 | AC | 15 ms
19,244 KB |
testcase_39 | AC | 15 ms
19,040 KB |
testcase_40 | AC | 16 ms
19,204 KB |
testcase_41 | AC | 16 ms
19,084 KB |
testcase_42 | AC | 15 ms
19,212 KB |
testcase_43 | AC | 16 ms
19,080 KB |
testcase_44 | AC | 15 ms
18,980 KB |
testcase_45 | AC | 15 ms
19,112 KB |
testcase_46 | AC | 15 ms
19,212 KB |
testcase_47 | AC | 16 ms
19,284 KB |
testcase_48 | AC | 15 ms
19,112 KB |
testcase_49 | AC | 15 ms
19,212 KB |
testcase_50 | AC | 15 ms
19,180 KB |
testcase_51 | AC | 15 ms
19,312 KB |
testcase_52 | AC | 15 ms
19,160 KB |
testcase_53 | AC | 15 ms
19,192 KB |
testcase_54 | AC | 15 ms
19,088 KB |
testcase_55 | AC | 16 ms
19,308 KB |
testcase_56 | AC | 15 ms
19,212 KB |
testcase_57 | AC | 16 ms
19,192 KB |
testcase_58 | AC | 15 ms
19,108 KB |
testcase_59 | AC | 15 ms
19,168 KB |
testcase_60 | AC | 16 ms
19,140 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef unsigned long long ull; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; typedef pair<double, double> pdd; const ull mod = 1e9 + 7; #define REP(i,n) for(int i=0;i<(int)n;++i) //debug #define dump(x) cerr << #x << " = " << (x) << endl; #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){ os << "(" << v.first << ", " << v.second << ")"; return os; } template<class T> ostream& operator << (ostream& os, const vector<T> v){ for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os; } template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){ for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os; } ll fact[2020202]; ll powLL(ll a, ll n){ ll res = 1; while(n>0){ if(n&1){ res *= a; } a = a*a; n >>= 1; } return res; } int main(){ cin.tie(0); ios::sync_with_stdio(false); fact[0] = 1; REP(i, 2020201){ fact[i+1] = fact[i]*(i+1); fact[i+1] %= mod; } ll d, l, r, k; cin >> d >> l >> r >> k; ll L=0, R=0; while(l>0){ l /= 2; L++; } while(r>0){ r /= 2; R++; } if(L>R) swap(L, R); ll res = 1; ll now = 1; if(k>=R-L && k<=R+L-2 && (k-(R-L))%2==0){ ll t = (k - (R-L))/2; //dump(t) REP(i, d){ if(i==L-1){ if(R==L){ res *= now; res %= mod; res *= (1ll<<(t-1)); res %= mod; res *= fact[now-2]; res %= mod; }else{ if(t != 0){ res *= (1ll<<(t-1)); res %= mod; } res *= fact[now-1]; res %= mod; } }else{ res *= fact[now]; } res %= mod; now *= 2; } }else{ res = 0; } cout << res << endl; return 0; }