結果
問題 | No.1036 Make One With GCD 2 |
ユーザー |
|
提出日時 | 2022-04-14 06:49:57 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 511 ms / 2,000 ms |
コード長 | 531 bytes |
コンパイル時間 | 1,969 ms |
コンパイル使用メモリ | 180,292 KB |
実行使用メモリ | 98,964 KB |
最終ジャッジ日時 | 2024-12-24 05:10:36 |
合計ジャッジ時間 | 12,592 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
importData.MaybeimportData.ListimportqualifiedData.ByteString.CharasBSmain=don<-fst.fromJust.BS.readInteger<$>BS.getLinea<-map(fst.fromJust.BS.readInteger).BS.words<$>BS.getLineprint$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=0f 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)