language: Haskell (ghc-6.8.2)
date: 112 days 5 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import Data.List
import qualified Data.ByteString.Char8 as BS
 
convertBase :: Integer -> [Integer]
convertBase 0 = []
convertBase n = (mod n  5)  : convertBase ( div n 5 ) 
 
 
 
readInt :: BS.ByteString -> Integer
readInt x = case BS.readInteger x of
              Just ( i , _ ) -> i
              Nothing -> error " upseperable ints "
 
 
solve :: Integer -> Integer 
solve 0 = 1
solve 1 = 1
solve n =  mod ( 6*fst a ) 10 where 
        a = foldl (\(acc , i ) x -> ( mod  ( acc *  product [1..x] * 2^(i*x) ) 10 , i + 1 ) ) ( 1 , 0 ) $ convertBase n 
 
 
main = BS.interact $ BS.unlines. map ( BS.pack . show . solve )  . map readInt. BS.lines
  • upload with new input
  • result: Success     time: 0.01s    memory: 3616 kB     returned value: 0

    45 29216 24198 17795 29484 19650 14590 26431 10705 18316 5557 28189 12652 606 32153 17829 29813 30367 6658 28961 11039 30085 18917 7167 14895 23440 5962 2424 29711 7512 8448 10095 28702 4489 19599 18588 27723 7212 21614 18921 27874 7976 1654 10012 3749 21512 18071 17079 16159 29438 10698 25884 20277 19240 15686 14069 5118 12307 19959 15059 2517 24702 17452 2581 11692 19040 26512 22796 163 20524 8027 1629 27097 29523 713 14758 27265 2058 19916 21860 22585 22095 3581 16404 4504 19494 7129 18584 24838 9513 13354 10717 465 11071 17859 29115 31613 29868 18288 
    6