結果

問題 No.443 GCD of Permutation
ユーザー atuk721atuk721
提出日時 2017-02-14 05:32:28
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 650 bytes
コンパイル時間 871 ms
コンパイル使用メモリ 165,612 KB
実行使用メモリ 11,812 KB
最終ジャッジ日時 2023-08-28 16:27:38
合計ジャッジ時間 2,242 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 3 ms
7,192 KB
testcase_02 WA -
testcase_03 AC 2 ms
7,332 KB
testcase_04 AC 3 ms
7,212 KB
testcase_05 AC 2 ms
6,960 KB
testcase_06 AC 2 ms
7,124 KB
testcase_07 AC 2 ms
7,156 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 3 ms
7,232 KB
testcase_11 AC 2 ms
7,208 KB
testcase_12 AC 2 ms
7,384 KB
testcase_13 AC 2 ms
7,112 KB
testcase_14 AC 7 ms
11,772 KB
testcase_15 WA -
testcase_16 AC 3 ms
8,012 KB
testcase_17 AC 3 ms
8,180 KB
testcase_18 AC 7 ms
11,352 KB
testcase_19 AC 3 ms
8,148 KB
testcase_20 AC 6 ms
11,128 KB
testcase_21 AC 4 ms
8,764 KB
testcase_22 AC 2 ms
7,332 KB
testcase_23 WA -
testcase_24 AC 2 ms
7,128 KB
testcase_25 AC 6 ms
11,476 KB
testcase_26 AC 6 ms
11,372 KB
testcase_27 AC 5 ms
9,308 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 6 ms
11,480 KB
testcase_31 AC 6 ms
11,532 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 qualified Data.Char as C
import qualified Data.List as L

main :: IO ()
main = do
  n <- getLine
  let ns = map C.digitToInt . L.nub $ n
      result = if length ns == 1
                  then read n
                  else proc (read n) $ createPattern ns

  print result

proc :: Integer -> [(Integer, Integer)] -> Integer
proc n ns = foldr gcd n ns'
  where ns' = map (\(a, b) -> 9 * (a - b)) ns

createPattern :: [Int] -> [(Integer, Integer)]
createPattern ns = map (\(x, y) -> (toInteger x, toInteger y)) ns'
  where pattern = [(x, y) | x <- [1..9], y <- [1..9], x > y]
        ns' = filter (\(x, y) -> x `elem` ns && y `elem` ns) pattern
0