結果
問題 | No.916 Encounter On A Tree |
ユーザー | mkawa2 |
提出日時 | 2021-04-02 14:25:45 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 806 ms / 2,000 ms |
コード長 | 1,745 bytes |
コンパイル時間 | 79 ms |
コンパイル使用メモリ | 12,928 KB |
実行使用メモリ | 93,184 KB |
最終ジャッジ日時 | 2024-06-02 11:51:36 |
合計ジャッジ時間 | 47,084 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 745 ms
93,056 KB |
testcase_01 | AC | 725 ms
93,000 KB |
testcase_02 | AC | 722 ms
92,928 KB |
testcase_03 | AC | 733 ms
93,056 KB |
testcase_04 | AC | 726 ms
92,984 KB |
testcase_05 | AC | 759 ms
92,928 KB |
testcase_06 | AC | 806 ms
93,004 KB |
testcase_07 | AC | 730 ms
92,928 KB |
testcase_08 | AC | 709 ms
92,972 KB |
testcase_09 | AC | 717 ms
92,916 KB |
testcase_10 | AC | 727 ms
92,920 KB |
testcase_11 | AC | 733 ms
93,024 KB |
testcase_12 | AC | 724 ms
93,056 KB |
testcase_13 | AC | 710 ms
92,924 KB |
testcase_14 | AC | 723 ms
92,960 KB |
testcase_15 | AC | 743 ms
92,928 KB |
testcase_16 | AC | 785 ms
92,928 KB |
testcase_17 | AC | 722 ms
93,056 KB |
testcase_18 | AC | 768 ms
93,184 KB |
testcase_19 | AC | 762 ms
93,056 KB |
testcase_20 | AC | 715 ms
93,056 KB |
testcase_21 | AC | 721 ms
93,184 KB |
testcase_22 | AC | 724 ms
93,184 KB |
testcase_23 | AC | 729 ms
93,056 KB |
testcase_24 | AC | 751 ms
92,928 KB |
testcase_25 | AC | 722 ms
93,056 KB |
testcase_26 | AC | 708 ms
93,100 KB |
testcase_27 | AC | 725 ms
93,184 KB |
testcase_28 | AC | 741 ms
92,916 KB |
testcase_29 | AC | 709 ms
93,056 KB |
testcase_30 | AC | 729 ms
93,008 KB |
testcase_31 | AC | 726 ms
92,928 KB |
testcase_32 | AC | 722 ms
92,960 KB |
testcase_33 | AC | 717 ms
93,184 KB |
testcase_34 | AC | 726 ms
93,056 KB |
testcase_35 | AC | 707 ms
92,972 KB |
testcase_36 | AC | 726 ms
93,056 KB |
testcase_37 | AC | 738 ms
92,968 KB |
testcase_38 | AC | 718 ms
92,928 KB |
testcase_39 | AC | 770 ms
93,044 KB |
testcase_40 | AC | 734 ms
92,928 KB |
testcase_41 | AC | 696 ms
93,056 KB |
testcase_42 | AC | 718 ms
92,928 KB |
testcase_43 | AC | 732 ms
92,928 KB |
testcase_44 | AC | 713 ms
92,928 KB |
testcase_45 | AC | 726 ms
93,104 KB |
testcase_46 | AC | 715 ms
92,928 KB |
testcase_47 | AC | 710 ms
93,056 KB |
testcase_48 | AC | 748 ms
92,964 KB |
testcase_49 | AC | 759 ms
92,944 KB |
testcase_50 | AC | 739 ms
92,928 KB |
testcase_51 | AC | 726 ms
93,184 KB |
testcase_52 | AC | 806 ms
93,056 KB |
testcase_53 | AC | 746 ms
93,040 KB |
testcase_54 | AC | 740 ms
93,056 KB |
testcase_55 | AC | 753 ms
92,928 KB |
testcase_56 | AC | 733 ms
92,804 KB |
testcase_57 | AC | 730 ms
92,988 KB |
testcase_58 | AC | 711 ms
93,056 KB |
testcase_59 | AC | 703 ms
92,928 KB |
testcase_60 | AC | 722 ms
92,916 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 or da > dl: print(0) exit() # print(dl, dr, da) 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)