結果
問題 | No.916 Encounter On A Tree |
ユーザー | どらら |
提出日時 | 2019-10-26 00:20:19 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,696 bytes |
コンパイル時間 | 1,564 ms |
コンパイル使用メモリ | 168,492 KB |
実行使用メモリ | 12,212 KB |
最終ジャッジ日時 | 2024-09-13 11:16:55 |
合計ジャッジ時間 | 3,723 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 10 ms
12,124 KB |
testcase_01 | AC | 13 ms
12,012 KB |
testcase_02 | AC | 11 ms
12,092 KB |
testcase_03 | AC | 10 ms
12,032 KB |
testcase_04 | AC | 11 ms
12,032 KB |
testcase_05 | WA | - |
testcase_06 | AC | 11 ms
11,968 KB |
testcase_07 | AC | 10 ms
12,028 KB |
testcase_08 | AC | 11 ms
12,032 KB |
testcase_09 | AC | 10 ms
12,004 KB |
testcase_10 | AC | 10 ms
12,032 KB |
testcase_11 | AC | 11 ms
12,032 KB |
testcase_12 | AC | 10 ms
11,904 KB |
testcase_13 | AC | 11 ms
12,032 KB |
testcase_14 | AC | 10 ms
12,032 KB |
testcase_15 | AC | 11 ms
11,904 KB |
testcase_16 | AC | 11 ms
11,904 KB |
testcase_17 | WA | - |
testcase_18 | AC | 11 ms
12,032 KB |
testcase_19 | AC | 11 ms
12,096 KB |
testcase_20 | AC | 11 ms
12,032 KB |
testcase_21 | WA | - |
testcase_22 | AC | 10 ms
12,008 KB |
testcase_23 | WA | - |
testcase_24 | AC | 11 ms
12,032 KB |
testcase_25 | AC | 10 ms
12,020 KB |
testcase_26 | AC | 11 ms
11,876 KB |
testcase_27 | AC | 11 ms
12,032 KB |
testcase_28 | AC | 11 ms
12,032 KB |
testcase_29 | WA | - |
testcase_30 | AC | 11 ms
12,028 KB |
testcase_31 | AC | 9 ms
12,032 KB |
testcase_32 | AC | 10 ms
12,144 KB |
testcase_33 | AC | 9 ms
11,888 KB |
testcase_34 | AC | 9 ms
11,968 KB |
testcase_35 | AC | 11 ms
12,032 KB |
testcase_36 | AC | 11 ms
12,124 KB |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | AC | 11 ms
12,016 KB |
testcase_40 | AC | 10 ms
12,032 KB |
testcase_41 | AC | 11 ms
12,016 KB |
testcase_42 | AC | 9 ms
12,032 KB |
testcase_43 | AC | 10 ms
11,904 KB |
testcase_44 | AC | 11 ms
11,904 KB |
testcase_45 | AC | 11 ms
12,008 KB |
testcase_46 | AC | 11 ms
11,992 KB |
testcase_47 | AC | 11 ms
12,160 KB |
testcase_48 | AC | 11 ms
11,952 KB |
testcase_49 | AC | 10 ms
12,032 KB |
testcase_50 | AC | 10 ms
11,904 KB |
testcase_51 | AC | 11 ms
12,032 KB |
testcase_52 | WA | - |
testcase_53 | AC | 11 ms
12,016 KB |
testcase_54 | AC | 10 ms
11,904 KB |
testcase_55 | AC | 11 ms
12,032 KB |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | AC | 11 ms
12,032 KB |
testcase_59 | WA | - |
testcase_60 | WA | - |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,a,n) for(int i=(a); i<(int)(n); i++) #define rep(i,n) REP(i,0,n) #define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it) #define ALLOF(c) (c).begin(), (c).end() typedef long long ll; typedef unsigned long long ull; static const ll MOD = 1000000007; ll fact[1100000]; int main(){ fact[0] = fact[1] = 1; for(ll i=2; i<1100000; i++) fact[i] = (fact[i-1] * i) % MOD; ll d, l, r, k; cin >> d >> l >> r >> k; ll li = 0, ri = 0; ll p = 1; REP(i,1,21){ if(p <= l && l < p*2){ li = i; } if(p <= r && r < p*2){ ri = i; } p *= 2; } if(k < (ri-li) || (k-(ri-li))%2 != 0){ cout << 0 << endl; }else{ ll a = (k-(ri-li))/2; ll lca = li-a; if(lca < 1){ cout << 0 << endl; return 0; } cerr << li << " " << ri << " " << a << " " << lca << endl; if(li == ri){ ll ln = 1LL << (li-1); ll rn = (1LL << (a-1)); ll ret = 1; REP(i,1,d+1){ if(i==ri){ ret *= ((ln%MOD) * (rn%MOD))%MOD; ret %= MOD; ret *= fact[(1LL << (ll)(i-1)) - 2]; ret %= MOD; }else{ ret *= fact[(1LL << (ll)(i-1))]; ret %= MOD; } } cout << ret << endl; }else{ ll ln = 1LL << (li-1); ll rn = 1LL << (ri-lca); ll ret = ((ln%MOD) * (rn%MOD))%MOD;; REP(i,1,d+1){ if(i==li || i==ri){ ret *= fact[(1LL << (ll)(i-1)) - 1]; ret %= MOD; } else{ ret *= fact[(1LL << (ll)(i-1))]; ret %= MOD; } } cout << ret << endl; } } return 0; }