結果

問題 No.1036 Make One With GCD 2
ユーザー kotatsugamekotatsugame
提出日時 2022-04-14 06:48:34
言語 Haskell
(9.6.1)
結果
AC  
実行時間 493 ms / 2,000 ms
コード長 532 bytes
コンパイル時間 1,561 ms
実行使用メモリ 92,152 KB
最終ジャッジ日時 2023-01-13 11:10:05
合計ジャッジ時間 13,898 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 358 ms
71,520 KB
testcase_01 AC 265 ms
56,668 KB
testcase_02 AC 274 ms
92,152 KB
testcase_03 AC 69 ms
26,188 KB
testcase_04 AC 126 ms
38,952 KB
testcase_05 AC 2 ms
6,948 KB
testcase_06 AC 2 ms
4,904 KB
testcase_07 AC 98 ms
31,040 KB
testcase_08 AC 81 ms
26,496 KB
testcase_09 AC 273 ms
55,244 KB
testcase_10 AC 256 ms
52,888 KB
testcase_11 AC 280 ms
56,400 KB
testcase_12 AC 258 ms
52,992 KB
testcase_13 AC 359 ms
59,316 KB
testcase_14 AC 364 ms
59,700 KB
testcase_15 AC 340 ms
56,828 KB
testcase_16 AC 343 ms
56,920 KB
testcase_17 AC 351 ms
58,812 KB
testcase_18 AC 3 ms
5,232 KB
testcase_19 AC 4 ms
6,952 KB
testcase_20 AC 5 ms
7,652 KB
testcase_21 AC 5 ms
7,368 KB
testcase_22 AC 337 ms
55,796 KB
testcase_23 AC 245 ms
44,916 KB
testcase_24 AC 349 ms
58,144 KB
testcase_25 AC 318 ms
53,180 KB
testcase_26 AC 337 ms
53,544 KB
testcase_27 AC 1 ms
4,900 KB
testcase_28 AC 2 ms
4,904 KB
testcase_29 AC 2 ms
4,904 KB
testcase_30 AC 2 ms
6,952 KB
testcase_31 AC 2 ms
4,900 KB
testcase_32 AC 2 ms
4,900 KB
testcase_33 AC 2 ms
4,908 KB
testcase_34 AC 2 ms
4,904 KB
testcase_35 AC 2 ms
4,904 KB
testcase_36 AC 2 ms
4,904 KB
testcase_37 AC 2 ms
4,904 KB
testcase_38 AC 280 ms
90,580 KB
testcase_39 AC 317 ms
60,836 KB
testcase_40 AC 243 ms
44,728 KB
testcase_41 AC 349 ms
61,088 KB
testcase_42 AC 358 ms
60,876 KB
testcase_43 AC 493 ms
88,664 KB
testcase_44 AC 481 ms
76,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.2.2/environments/default
[1 of 1] Compiling Main             ( Main.hs, Main.o )
Linking a.out ...

ソースコード

diff #

import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS
main=do
 n<-fst.fromJust.BS.readInteger<$>BS.getLine
 a<-map(fst.fromJust.BS.readInteger).BS.words<$>BS.getLine
 print$f (n+1) a [(0,0)] [(0,0)]

f n a [] r=f n a (drop 2$reverse$scanl' (\(_,s) (e,_)->(e,s`gcd`e)) (0,0) r) [(0,0)]

f n [] ((el,sl):l) ((er,sr):r)
 |sl`gcd`sr==1=n+f n [] l ((er,sr):r)
 |otherwise=0

f n (a:as) ((el,sl):l) ((er,sr):r)
 |sl`gcd`sr==1=n+f n (a:as) l ((er,sr):r)
 |otherwise=f (n-1) as ((el,sl):l) ((a,sr`gcd`a):(er,sr):r)
0