結果

問題 No.443 GCD of Permutation
ユーザー atuk721atuk721
提出日時 2017-02-14 05:35:06
言語 Haskell
(9.6.2)
結果
AC  
実行時間 13 ms / 1,000 ms
コード長 650 bytes
コンパイル時間 12,096 ms
コンパイル使用メモリ 165,724 KB
実行使用メモリ 11,828 KB
最終ジャッジ日時 2023-08-04 03:01:53
合計ジャッジ時間 2,377 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,172 KB
testcase_01 AC 2 ms
7,132 KB
testcase_02 AC 2 ms
7,172 KB
testcase_03 AC 2 ms
7,260 KB
testcase_04 AC 2 ms
7,144 KB
testcase_05 AC 2 ms
6,976 KB
testcase_06 AC 2 ms
7,260 KB
testcase_07 AC 2 ms
7,268 KB
testcase_08 AC 2 ms
7,172 KB
testcase_09 AC 3 ms
7,244 KB
testcase_10 AC 2 ms
7,136 KB
testcase_11 AC 2 ms
7,252 KB
testcase_12 AC 2 ms
7,312 KB
testcase_13 AC 3 ms
7,212 KB
testcase_14 AC 8 ms
11,828 KB
testcase_15 AC 4 ms
8,680 KB
testcase_16 AC 3 ms
7,780 KB
testcase_17 AC 4 ms
8,216 KB
testcase_18 AC 7 ms
11,332 KB
testcase_19 AC 3 ms
8,096 KB
testcase_20 AC 13 ms
11,132 KB
testcase_21 AC 4 ms
8,720 KB
testcase_22 AC 2 ms
7,340 KB
testcase_23 AC 3 ms
7,176 KB
testcase_24 AC 2 ms
7,316 KB
testcase_25 AC 7 ms
11,456 KB
testcase_26 AC 6 ms
11,372 KB
testcase_27 AC 5 ms
9,308 KB
testcase_28 AC 6 ms
11,496 KB
testcase_29 AC 7 ms
11,536 KB
testcase_30 AC 7 ms
11,640 KB
testcase_31 AC 12 ms
11,520 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 <- [0..9], y <- [0..9], x > y]
        ns' = filter (\(x, y) -> x `elem` ns && y `elem` ns) pattern
0