結果

問題 No.1501 酔歩
ユーザー kozykozy
提出日時 2021-05-08 00:29:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 508 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 11,040 KB
実行使用メモリ 22,388 KB
最終ジャッジ日時 2023-10-13 16:37:42
合計ジャッジ時間 11,122 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
8,292 KB
testcase_01 AC 14 ms
8,268 KB
testcase_02 AC 14 ms
8,320 KB
testcase_03 AC 14 ms
8,412 KB
testcase_04 WA -
testcase_05 AC 203 ms
19,288 KB
testcase_06 AC 160 ms
16,680 KB
testcase_07 AC 197 ms
18,732 KB
testcase_08 AC 56 ms
10,892 KB
testcase_09 AC 175 ms
17,732 KB
testcase_10 AC 76 ms
11,744 KB
testcase_11 AC 158 ms
16,540 KB
testcase_12 AC 118 ms
14,144 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 252 ms
22,308 KB
testcase_23 AC 261 ms
22,216 KB
testcase_24 AC 263 ms
22,388 KB
testcase_25 AC 255 ms
22,360 KB
testcase_26 AC 266 ms
22,152 KB
testcase_27 AC 270 ms
22,208 KB
testcase_28 AC 265 ms
22,324 KB
testcase_29 AC 262 ms
22,168 KB
testcase_30 AC 261 ms
22,152 KB
testcase_31 AC 257 ms
22,300 KB
testcase_32 AC 267 ms
22,220 KB
testcase_33 AC 261 ms
22,304 KB
testcase_34 AC 254 ms
22,288 KB
testcase_35 AC 281 ms
22,328 KB
testcase_36 AC 276 ms
22,284 KB
testcase_37 AC 264 ms
22,304 KB
testcase_38 AC 255 ms
22,216 KB
testcase_39 AC 267 ms
22,228 KB
testcase_40 AC 256 ms
22,232 KB
testcase_41 AC 268 ms
22,352 KB
testcase_42 AC 206 ms
19,228 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 204 ms
19,212 KB
testcase_46 AC 197 ms
19,312 KB
testcase_47 AC 202 ms
19,300 KB
testcase_48 AC 210 ms
19,328 KB
testcase_49 AC 213 ms
19,240 KB
testcase_50 AC 218 ms
19,204 KB
testcase_51 AC 246 ms
19,376 KB
testcase_52 AC 210 ms
19,324 KB
testcase_53 WA -
testcase_54 AC 14 ms
8,328 KB
testcase_55 AC 14 ms
8,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
def plus(a,b,c,d):
  x,y=(a*d+b*c),b*d
  g=math.gcd(x,y)
  if x<=0 and y<=0:
      x,y=-x,-y
  return x//g,y//g
N,K=map(int,input().split())
A=list(map(int,input().split()))
if N==1:
  print(1)
  exit()
L=[0]*N
L[0]=[0,1]
L[1]=[1,1]
for i in range(1,N-1):
  a=A[i-1]
  b=A[i+1]
  n1,m1=L[i-1]
  n2,m2=L[i]
  x,y=plus((a+b)*n2,m2,-n1*a,m1)
  g=math.gcd(x,y*b)
  L[i+1]=x//g,y*b//g
a,b=L[K-1]
c,d=L[-1]
x,y=a*d,c*b
g=math.gcd(x,y)
x,y=x//g,y//g
if x==0:
  print(0)
  exit()
print(str(x)+"/"+str(y))
0