結果
問題 |
No.443 GCD of Permutation
|
ユーザー |
![]() |
提出日時 | 2017-02-14 05:00:26 |
言語 | Haskell (9.10.1) |
結果 |
MLE
|
実行時間 | - |
コード長 | 584 bytes |
コンパイル時間 | 9,017 ms |
コンパイル使用メモリ | 173,312 KB |
実行使用メモリ | 746,660 KB |
最終ジャッジ日時 | 2024-12-29 21:02:27 |
合計ジャッジ時間 | 11,743 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 MLE * 2 |
other | AC * 23 TLE * 3 MLE * 2 |
コンパイルメッセージ
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
ソースコード
import qualified Data.Char as C import qualified Data.List as L main :: IO () main = do n <- getLine let ns = L.permutations . L.nub $ n result = if length ns == 1 then read n else proc (read n) $ convert ns print result proc :: Integer -> [(Integer, Integer)] -> Integer proc n ns = foldr gcd n ns'' where ns' = L.nub . filter (\(x, y) -> x > y) $ ns ns'' = map (\(a, b) -> 9 * (a - b)) ns' convert :: [String] -> [(Integer, Integer)] convert = map (\(x:y:zs) -> (toInteger $ C.digitToInt x, toInteger $ C.digitToInt y))