結果

問題 No.443 GCD of Permutation
ユーザー pekempeypekempey
提出日時 2016-11-23 04:05:44
言語 Haskell
(9.6.2)
結果
AC  
実行時間 12 ms / 1,000 ms
コード長 347 bytes
コンパイル時間 9,822 ms
コンパイル使用メモリ 165,908 KB
実行使用メモリ 12,052 KB
最終ジャッジ日時 2023-08-04 02:59:00
合計ジャッジ時間 11,483 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,424 KB
testcase_01 AC 3 ms
7,156 KB
testcase_02 AC 3 ms
7,224 KB
testcase_03 AC 2 ms
7,416 KB
testcase_04 AC 2 ms
7,260 KB
testcase_05 AC 2 ms
7,152 KB
testcase_06 AC 3 ms
7,212 KB
testcase_07 AC 3 ms
7,352 KB
testcase_08 AC 2 ms
7,336 KB
testcase_09 AC 2 ms
7,388 KB
testcase_10 AC 3 ms
7,208 KB
testcase_11 AC 3 ms
7,276 KB
testcase_12 AC 2 ms
7,272 KB
testcase_13 AC 2 ms
7,348 KB
testcase_14 AC 12 ms
12,052 KB
testcase_15 AC 5 ms
9,088 KB
testcase_16 AC 4 ms
8,036 KB
testcase_17 AC 3 ms
8,324 KB
testcase_18 AC 8 ms
11,608 KB
testcase_19 AC 3 ms
8,196 KB
testcase_20 AC 6 ms
11,076 KB
testcase_21 AC 4 ms
8,760 KB
testcase_22 AC 3 ms
7,356 KB
testcase_23 AC 3 ms
7,264 KB
testcase_24 AC 2 ms
7,384 KB
testcase_25 AC 12 ms
11,648 KB
testcase_26 AC 12 ms
11,552 KB
testcase_27 AC 5 ms
9,760 KB
testcase_28 AC 12 ms
11,620 KB
testcase_29 AC 12 ms
11,780 KB
testcase_30 AC 12 ms
11,704 KB
testcase_31 AC 7 ms
11,576 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.Char (digitToInt)

digits :: String -> [Int]
digits n = let m = map digitToInt n in filter (flip elem m) [0 .. 9]

solve :: String -> Integer
solve s = gcd n $ fromIntegral (foldr gcd 0 [abs (x - y) * 9 | x <- ds, y <- ds])
    where
        n = read s :: Integer
        ds = digits s

main :: IO ()
main = getLine >>= print . solve

0