結果
問題 | No.916 Encounter On A Tree |
ユーザー | mkawa2 |
提出日時 | 2021-04-02 14:12:32 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,714 bytes |
コンパイル時間 | 80 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 93,184 KB |
最終ジャッジ日時 | 2024-06-02 11:34:28 |
合計ジャッジ時間 | 47,637 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 727 ms
93,056 KB |
testcase_02 | AC | 734 ms
93,056 KB |
testcase_03 | AC | 750 ms
93,184 KB |
testcase_04 | AC | 746 ms
92,928 KB |
testcase_05 | AC | 737 ms
92,928 KB |
testcase_06 | WA | - |
testcase_07 | AC | 747 ms
92,928 KB |
testcase_08 | AC | 736 ms
93,184 KB |
testcase_09 | AC | 727 ms
92,928 KB |
testcase_10 | AC | 726 ms
93,056 KB |
testcase_11 | AC | 795 ms
92,928 KB |
testcase_12 | AC | 759 ms
93,056 KB |
testcase_13 | AC | 725 ms
92,928 KB |
testcase_14 | AC | 728 ms
93,184 KB |
testcase_15 | AC | 728 ms
92,928 KB |
testcase_16 | AC | 749 ms
93,184 KB |
testcase_17 | AC | 754 ms
92,928 KB |
testcase_18 | AC | 726 ms
92,928 KB |
testcase_19 | AC | 762 ms
92,800 KB |
testcase_20 | WA | - |
testcase_21 | AC | 742 ms
93,056 KB |
testcase_22 | AC | 752 ms
93,056 KB |
testcase_23 | AC | 723 ms
92,928 KB |
testcase_24 | AC | 743 ms
93,056 KB |
testcase_25 | AC | 728 ms
92,928 KB |
testcase_26 | AC | 712 ms
93,056 KB |
testcase_27 | AC | 754 ms
92,928 KB |
testcase_28 | AC | 738 ms
92,928 KB |
testcase_29 | AC | 723 ms
92,928 KB |
testcase_30 | AC | 760 ms
92,928 KB |
testcase_31 | AC | 760 ms
93,056 KB |
testcase_32 | AC | 720 ms
93,056 KB |
testcase_33 | AC | 724 ms
92,800 KB |
testcase_34 | AC | 734 ms
93,056 KB |
testcase_35 | AC | 778 ms
92,800 KB |
testcase_36 | AC | 731 ms
93,184 KB |
testcase_37 | AC | 733 ms
92,928 KB |
testcase_38 | AC | 709 ms
92,928 KB |
testcase_39 | AC | 736 ms
93,116 KB |
testcase_40 | AC | 743 ms
93,088 KB |
testcase_41 | AC | 730 ms
92,908 KB |
testcase_42 | AC | 733 ms
93,040 KB |
testcase_43 | AC | 721 ms
92,936 KB |
testcase_44 | AC | 734 ms
92,928 KB |
testcase_45 | AC | 736 ms
93,056 KB |
testcase_46 | AC | 749 ms
93,000 KB |
testcase_47 | AC | 722 ms
93,184 KB |
testcase_48 | AC | 731 ms
92,992 KB |
testcase_49 | AC | 744 ms
93,184 KB |
testcase_50 | AC | 732 ms
92,928 KB |
testcase_51 | AC | 744 ms
92,928 KB |
testcase_52 | AC | 744 ms
92,928 KB |
testcase_53 | AC | 735 ms
92,928 KB |
testcase_54 | AC | 771 ms
92,928 KB |
testcase_55 | AC | 733 ms
92,928 KB |
testcase_56 | AC | 760 ms
92,912 KB |
testcase_57 | AC | 737 ms
92,928 KB |
testcase_58 | AC | 722 ms
93,056 KB |
testcase_59 | AC | 744 ms
92,980 KB |
testcase_60 | AC | 720 ms
92,928 KB |
ソースコード
import sys sys.setrecursionlimit(10**6) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() # dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 def nHr(hn, hr): return nCr(hn+hr-1, hr-1) def nPr(com_n, com_r): if com_r < 0: return 0 if com_n < com_r: return 0 return fac[com_n]*ifac[com_n-com_r]%md def nCr(com_n, com_r): if com_r < 0: return 0 if com_n < com_r: return 0 return fac[com_n]*ifac[com_r]%md*ifac[com_n-com_r]%md # 準備 n_max = (1 << 20)+5 fac = [1] for i in range(1, n_max+1): fac.append(fac[-1]*i%md) ifac = [1]*(n_max+1) ifac[n_max] = pow(fac[n_max], md-2, md) for i in range(n_max-1, 1, -1): ifac[i] = ifac[i+1]*(i+1)%md d, l, r, k = LI() dl = l.bit_length()-1 dr = r.bit_length()-1 if (dl+dr-k) & 1: print(0) exit() da = (dl+dr-k)//2 if da < 0: print(0) exit() ans = 1 w = 1 for i in range(d): if i == dr: if dl == dr: ans *= w*(1 << dr-da-1)*nPr(w-2, w-2) elif da == dl: ans *= (1 << dr-da)*nPr(w-1, w-1) else: ans *= (1 << dr-da-1)*nPr(w-1, w-1) else: ans *= nPr(w, w) ans %= md w <<= 1 print(ans)