結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,288 KB
testcase_01 AC 14 ms
8,316 KB
testcase_02 AC 15 ms
8,244 KB
testcase_03 AC 14 ms
8,316 KB
testcase_04 AC 15 ms
8,488 KB
testcase_05 AC 202 ms
19,428 KB
testcase_06 AC 157 ms
16,788 KB
testcase_07 AC 210 ms
18,908 KB
testcase_08 AC 58 ms
10,848 KB
testcase_09 AC 173 ms
17,628 KB
testcase_10 AC 76 ms
11,668 KB
testcase_11 AC 153 ms
16,480 KB
testcase_12 AC 114 ms
14,176 KB
testcase_13 AC 14 ms
8,408 KB
testcase_14 AC 14 ms
8,248 KB
testcase_15 AC 14 ms
8,316 KB
testcase_16 AC 14 ms
8,428 KB
testcase_17 AC 14 ms
8,428 KB
testcase_18 AC 14 ms
8,284 KB
testcase_19 AC 13 ms
8,384 KB
testcase_20 AC 14 ms
8,412 KB
testcase_21 AC 14 ms
8,288 KB
testcase_22 AC 255 ms
22,312 KB
testcase_23 AC 251 ms
22,204 KB
testcase_24 AC 258 ms
22,212 KB
testcase_25 AC 266 ms
22,224 KB
testcase_26 AC 260 ms
22,328 KB
testcase_27 AC 266 ms
22,172 KB
testcase_28 AC 256 ms
22,188 KB
testcase_29 AC 266 ms
22,296 KB
testcase_30 AC 259 ms
22,312 KB
testcase_31 AC 258 ms
22,172 KB
testcase_32 AC 262 ms
22,304 KB
testcase_33 AC 260 ms
22,184 KB
testcase_34 AC 263 ms
22,220 KB
testcase_35 AC 259 ms
22,220 KB
testcase_36 AC 264 ms
22,316 KB
testcase_37 AC 267 ms
22,324 KB
testcase_38 AC 284 ms
22,284 KB
testcase_39 AC 261 ms
22,400 KB
testcase_40 AC 248 ms
22,224 KB
testcase_41 AC 265 ms
22,364 KB
testcase_42 AC 207 ms
19,212 KB
testcase_43 AC 15 ms
8,492 KB
testcase_44 AC 14 ms
8,428 KB
testcase_45 AC 216 ms
19,316 KB
testcase_46 AC 201 ms
19,132 KB
testcase_47 AC 195 ms
19,340 KB
testcase_48 AC 215 ms
19,228 KB
testcase_49 AC 225 ms
19,320 KB
testcase_50 AC 247 ms
19,212 KB
testcase_51 AC 252 ms
19,400 KB
testcase_52 AC 240 ms
19,400 KB
testcase_53 AC 15 ms
8,316 KB
testcase_54 AC 17 ms
8,320 KB
testcase_55 AC 16 ms
8,428 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/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