Submission #8508807
Source Code Expand
def xgcd a, b
x, y, u, v = 1, 0, 0, 1
until b == 0
q, a, b = a/b, b, a%b
x, y, u, v = u, v, x-q*u, y-q*v
end
return a, x, y
end
def imod a, m
d, x, y = xgcd a, m
return nil unless d == 1
return 0<x ? x : x+m
end
X, Y = gets.split.map(&:to_i)
MOD = 1000000007
(p 0; exit) unless (X+Y)%3 == 0
L, R = [Y-(X+Y)/3, 2*(X+Y)/3-Y].minmax
(p 0; exit) if L < 0
p((R+1..L+R).inject(1){|s,n| s*n%MOD } * imod((1..L).inject(1){|s,d| s*d%MOD },MOD) % MOD)
Submission Info
Submission Time
2019-11-18 08:57:24+0900
Task
D - Knight
User
ds14050
Language
Ruby (2.3.3)
Score
400
Code Size
474 Byte
Status
AC
Exec Time
76 ms
Memory
1788 KiB
Compile Error
./Main.rb:10: warning: assigned but unused variable - y
Judge Result
Set Name
Sample
All
Score / Max Score
0 / 0
400 / 400
Status
Set Name
Test Cases
Sample
sample_01, sample_02, sample_03
All
hand_01, hand_02, hand_03, hand_04, random_01, random_02, random_03, random_04, random_05, random_06, random_07, random_08, random_09, random_10, random_11, random_12, random_13, random_14, random_15, random_16, random_17, random_18, random_19, random_20, random_21, random_22, random_23, random_24, sample_01, sample_02, sample_03
Case Name
Status
Exec Time
Memory
hand_01
AC
7 ms
1788 KiB
hand_02
AC
7 ms
1788 KiB
hand_03
AC
7 ms
1788 KiB
hand_04
AC
7 ms
1788 KiB
random_01
AC
7 ms
1788 KiB
random_02
AC
7 ms
1788 KiB
random_03
AC
7 ms
1788 KiB
random_04
AC
7 ms
1788 KiB
random_05
AC
7 ms
1788 KiB
random_06
AC
7 ms
1788 KiB
random_07
AC
7 ms
1788 KiB
random_08
AC
7 ms
1788 KiB
random_09
AC
7 ms
1788 KiB
random_10
AC
35 ms
1788 KiB
random_11
AC
7 ms
1788 KiB
random_12
AC
34 ms
1788 KiB
random_13
AC
34 ms
1788 KiB
random_14
AC
25 ms
1788 KiB
random_15
AC
22 ms
1788 KiB
random_16
AC
7 ms
1788 KiB
random_17
AC
74 ms
1788 KiB
random_18
AC
73 ms
1788 KiB
random_19
AC
74 ms
1788 KiB
random_20
AC
74 ms
1788 KiB
random_21
AC
76 ms
1788 KiB
random_22
AC
74 ms
1788 KiB
random_23
AC
75 ms
1788 KiB
random_24
AC
73 ms
1788 KiB
sample_01
AC
7 ms
1788 KiB
sample_02
AC
7 ms
1788 KiB
sample_03
AC
74 ms
1788 KiB