結果
| 問題 | No.443 GCD of Permutation |
| コンテスト | |
| ユーザー |
atuk721
|
| 提出日時 | 2017-02-14 05:00:26 |
| 言語 | Haskell (9.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 584 bytes |
| 記録 | |
| コンパイル時間 | 7,980 ms |
| コンパイル使用メモリ | 194,048 KB |
| 実行使用メモリ | 905,088 KB |
| 最終ジャッジ日時 | 2026-06-03 14:49:26 |
| 合計ジャッジ時間 | 15,111 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 TLE * 3 MLE * 1 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/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))
atuk721