結果

問題 No.1036 Make One With GCD 2
ユーザー kotatsugamekotatsugame
提出日時 2022-04-14 06:49:57
言語 Haskell
(9.8.2)
結果
AC  
実行時間 784 ms / 2,000 ms
コード長 531 bytes
コンパイル時間 842 ms
コンパイル使用メモリ 164,244 KB
実行使用メモリ 94,920 KB
最終ジャッジ日時 2023-08-25 19:12:12
合計ジャッジ時間 16,925 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 654 ms
77,544 KB
testcase_01 AC 363 ms
60,116 KB
testcase_02 AC 302 ms
92,904 KB
testcase_03 AC 72 ms
29,556 KB
testcase_04 AC 122 ms
42,416 KB
testcase_05 AC 2 ms
7,204 KB
testcase_06 AC 3 ms
7,244 KB
testcase_07 AC 142 ms
35,368 KB
testcase_08 AC 123 ms
30,096 KB
testcase_09 AC 264 ms
60,032 KB
testcase_10 AC 252 ms
56,188 KB
testcase_11 AC 263 ms
60,068 KB
testcase_12 AC 253 ms
56,252 KB
testcase_13 AC 552 ms
63,164 KB
testcase_14 AC 573 ms
63,108 KB
testcase_15 AC 513 ms
60,268 KB
testcase_16 AC 562 ms
60,272 KB
testcase_17 AC 563 ms
62,252 KB
testcase_18 AC 3 ms
8,396 KB
testcase_19 AC 4 ms
9,096 KB
testcase_20 AC 6 ms
10,964 KB
testcase_21 AC 5 ms
10,636 KB
testcase_22 AC 513 ms
59,184 KB
testcase_23 AC 382 ms
48,212 KB
testcase_24 AC 531 ms
61,488 KB
testcase_25 AC 503 ms
55,644 KB
testcase_26 AC 513 ms
56,996 KB
testcase_27 AC 2 ms
7,300 KB
testcase_28 AC 2 ms
7,108 KB
testcase_29 AC 2 ms
7,104 KB
testcase_30 AC 2 ms
7,328 KB
testcase_31 AC 3 ms
7,420 KB
testcase_32 AC 3 ms
7,492 KB
testcase_33 AC 2 ms
7,188 KB
testcase_34 AC 3 ms
7,436 KB
testcase_35 AC 2 ms
7,420 KB
testcase_36 AC 3 ms
7,400 KB
testcase_37 AC 2 ms
7,372 KB
testcase_38 AC 485 ms
88,800 KB
testcase_39 AC 524 ms
65,456 KB
testcase_40 AC 373 ms
48,264 KB
testcase_41 AC 604 ms
65,484 KB
testcase_42 AC 592 ms
61,884 KB
testcase_43 AC 784 ms
94,920 KB
testcase_44 AC 753 ms
83,704 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] 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$scanr (\(e,_) (_,s)->(e,s`gcd`e)) (0,0)$reverse$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