結果

問題 No.443 GCD of Permutation
ユーザー atuk721atuk721
提出日時 2017-02-14 05:46:08
言語 Haskell
(9.6.2)
結果
AC  
実行時間 7 ms / 1,000 ms
コード長 574 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 166,860 KB
実行使用メモリ 11,660 KB
最終ジャッジ日時 2023-08-04 03:02:30
合計ジャッジ時間 2,315 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,004 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
7,192 KB
testcase_03 AC 2 ms
7,112 KB
testcase_04 AC 2 ms
7,032 KB
testcase_05 AC 2 ms
6,816 KB
testcase_06 AC 2 ms
7,124 KB
testcase_07 AC 3 ms
7,072 KB
testcase_08 AC 2 ms
7,140 KB
testcase_09 AC 3 ms
7,028 KB
testcase_10 AC 3 ms
7,164 KB
testcase_11 AC 3 ms
7,140 KB
testcase_12 AC 2 ms
7,120 KB
testcase_13 AC 2 ms
7,124 KB
testcase_14 AC 7 ms
11,660 KB
testcase_15 AC 4 ms
8,604 KB
testcase_16 AC 3 ms
7,756 KB
testcase_17 AC 3 ms
7,964 KB
testcase_18 AC 6 ms
11,204 KB
testcase_19 AC 3 ms
7,976 KB
testcase_20 AC 7 ms
10,932 KB
testcase_21 AC 4 ms
8,588 KB
testcase_22 AC 2 ms
7,212 KB
testcase_23 AC 2 ms
7,112 KB
testcase_24 AC 2 ms
7,004 KB
testcase_25 AC 7 ms
11,416 KB
testcase_26 AC 6 ms
11,208 KB
testcase_27 AC 4 ms
9,152 KB
testcase_28 AC 6 ms
11,264 KB
testcase_29 AC 6 ms
11,488 KB
testcase_30 AC 6 ms
11,596 KB
testcase_31 AC 7 ms
11,408 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 (toInteger . C.digitToInt) . L.nub $ n

  print $ if length ns == 1
            then read n
            else proc (read n) $ createPattern ns

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

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