結果
問題 | No.1683 Robot Guidance |
ユーザー | tamato |
提出日時 | 2021-09-17 22:01:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 106 ms / 2,000 ms |
コード長 | 1,882 bytes |
コンパイル時間 | 170 ms |
コンパイル使用メモリ | 81,988 KB |
実行使用メモリ | 89,644 KB |
最終ジャッジ日時 | 2024-06-29 20:29:19 |
合計ジャッジ時間 | 5,185 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 87 ms
83,340 KB |
testcase_01 | AC | 85 ms
83,208 KB |
testcase_02 | AC | 89 ms
83,604 KB |
testcase_03 | AC | 96 ms
89,644 KB |
testcase_04 | AC | 95 ms
88,084 KB |
testcase_05 | AC | 93 ms
88,468 KB |
testcase_06 | AC | 96 ms
88,272 KB |
testcase_07 | AC | 94 ms
89,440 KB |
testcase_08 | AC | 106 ms
88,292 KB |
testcase_09 | AC | 95 ms
88,408 KB |
testcase_10 | AC | 99 ms
89,536 KB |
testcase_11 | AC | 97 ms
87,756 KB |
testcase_12 | AC | 105 ms
88,296 KB |
testcase_13 | AC | 83 ms
82,340 KB |
testcase_14 | AC | 101 ms
88,020 KB |
testcase_15 | AC | 92 ms
88,296 KB |
testcase_16 | AC | 81 ms
83,456 KB |
testcase_17 | AC | 83 ms
82,948 KB |
testcase_18 | AC | 83 ms
82,844 KB |
testcase_19 | AC | 81 ms
83,244 KB |
testcase_20 | AC | 82 ms
83,560 KB |
testcase_21 | AC | 81 ms
84,012 KB |
testcase_22 | AC | 80 ms
82,488 KB |
testcase_23 | AC | 83 ms
82,340 KB |
testcase_24 | AC | 106 ms
88,688 KB |
testcase_25 | AC | 82 ms
82,276 KB |
testcase_26 | AC | 81 ms
83,060 KB |
testcase_27 | AC | 82 ms
83,120 KB |
testcase_28 | AC | 83 ms
82,276 KB |
testcase_29 | AC | 83 ms
82,416 KB |
testcase_30 | AC | 85 ms
83,936 KB |
testcase_31 | AC | 87 ms
84,292 KB |
testcase_32 | AC | 87 ms
83,076 KB |
testcase_33 | AC | 83 ms
83,108 KB |
testcase_34 | AC | 84 ms
82,964 KB |
testcase_35 | AC | 84 ms
83,796 KB |
testcase_36 | AC | 87 ms
81,788 KB |
testcase_37 | AC | 85 ms
83,652 KB |
testcase_38 | AC | 95 ms
88,616 KB |
testcase_39 | AC | 86 ms
83,668 KB |
testcase_40 | AC | 90 ms
81,996 KB |
ソースコード
mod = 1000000007 eps = 10**-9 def main(): import sys input = sys.stdin.readline # comb init # mod = 1000000007 nmax = 10 ** 6 + 10 # change here fac = [0] * nmax finv = [0] * nmax inv = [0] * nmax fac[0] = 1 fac[1] = 1 finv[0] = 1 finv[1] = 1 inv[1] = 1 for i in range(2, nmax): fac[i] = fac[i - 1] * i % mod inv[i] = mod - inv[mod % i] * (mod // i) % mod finv[i] = finv[i - 1] * inv[i] % mod def comb(n, r): if n < r: return 0 else: return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod a, b, x, y = map(int, input().split()) if (x + y)%2 != a % 2: print(0) exit() if b == 0: if a == x and y == 0: print(1) else: print(0) exit() if b == 1: if x < 0 or y < 0: print(0) elif a != x + y: print(0) else: print(1) exit() if b == 2: if y < 0: print(0) else: aa = a - y print(1) exit() ans = 0 Z = (a - abs(x) - abs(y)) // 2 xp = xn = yp = yn = (b+1) // 4 if b%4 == 0: xp += 1 elif b%4 == 1: xp += 1 yp += 1 elif b%4 == 2: xp += 1 yp += 1 xn += 1 for zx in range(Z+1): zy = Z - zx nx = abs(x) + 2 * zx ny = abs(y) + 2 * zy nxp = (nx + x) // 2 nxn = nx - nxp nyp = (ny + y) // 2 nyn = ny - nyp tmp = 1 tmp = (tmp * comb(xp + nxp - 1, xp-1))%mod tmp = (tmp * comb(xn + nxn - 1, xn - 1)) % mod tmp = (tmp * comb(yp + nyp - 1, yp - 1)) % mod tmp = (tmp * comb(yn + nyn - 1, yn - 1)) % mod ans = (ans + tmp)%mod print(ans) if __name__ == '__main__': main()