結果

問題 No.1501 酔歩
ユーザー kozykozy
提出日時 2021-05-07 22:19:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 479 bytes
コンパイル時間 576 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 22,368 KB
最終ジャッジ日時 2023-10-13 13:31:17
合計ジャッジ時間 12,038 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,440 KB
testcase_01 AC 17 ms
8,444 KB
testcase_02 AC 16 ms
8,380 KB
testcase_03 AC 16 ms
8,280 KB
testcase_04 RE -
testcase_05 AC 228 ms
19,400 KB
testcase_06 AC 180 ms
16,664 KB
testcase_07 AC 219 ms
18,760 KB
testcase_08 AC 65 ms
10,916 KB
testcase_09 AC 193 ms
17,556 KB
testcase_10 AC 87 ms
11,768 KB
testcase_11 AC 174 ms
16,316 KB
testcase_12 AC 129 ms
14,128 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 AC 292 ms
22,348 KB
testcase_23 AC 291 ms
22,168 KB
testcase_24 AC 289 ms
22,292 KB
testcase_25 AC 288 ms
22,220 KB
testcase_26 AC 291 ms
22,176 KB
testcase_27 AC 287 ms
22,324 KB
testcase_28 AC 289 ms
22,332 KB
testcase_29 AC 293 ms
22,196 KB
testcase_30 AC 288 ms
22,216 KB
testcase_31 AC 297 ms
22,156 KB
testcase_32 AC 292 ms
22,196 KB
testcase_33 AC 291 ms
22,280 KB
testcase_34 AC 287 ms
22,296 KB
testcase_35 AC 290 ms
22,340 KB
testcase_36 AC 290 ms
22,368 KB
testcase_37 AC 287 ms
22,140 KB
testcase_38 AC 297 ms
22,296 KB
testcase_39 AC 293 ms
22,172 KB
testcase_40 AC 286 ms
22,284 KB
testcase_41 AC 304 ms
22,244 KB
testcase_42 AC 232 ms
19,196 KB
testcase_43 RE -
testcase_44 RE -
testcase_45 AC 228 ms
19,204 KB
testcase_46 AC 223 ms
19,136 KB
testcase_47 AC 224 ms
19,292 KB
testcase_48 AC 241 ms
19,232 KB
testcase_49 AC 228 ms
19,272 KB
testcase_50 AC 237 ms
19,356 KB
testcase_51 AC 249 ms
19,404 KB
testcase_52 AC 233 ms
19,224 KB
testcase_53 RE -
testcase_54 AC 16 ms
8,304 KB
testcase_55 AC 16 ms
8,492 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()))
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