September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,16 +1,20 @@
|
|||
import Data.List (transpose)
|
||||
import Data.List (transpose, inits)
|
||||
import Data.Char (digitToInt)
|
||||
import Data.List (inits)
|
||||
|
||||
digits :: Integer -> [Integer]
|
||||
digits = map (fromIntegral . digitToInt) . show
|
||||
digits = fmap (fromIntegral . digitToInt) . show
|
||||
|
||||
lZZ :: [[Integer]]
|
||||
lZZ = inits $ repeat 0
|
||||
|
||||
table f = map . flip (map . f)
|
||||
table :: (Integer -> Integer -> Integer) -> [Integer] -> [Integer] -> [[Integer]]
|
||||
table f x = fmap $ flip fmap x . f
|
||||
|
||||
polymul = ((map sum . transpose . zipWith (++) lZZ) .) . table (*)
|
||||
polymul :: [Integer] -> [Integer] -> [Integer]
|
||||
polymul xs ys = fmap sum (transpose (zipWith (++) lZZ (table (*) xs ys)))
|
||||
|
||||
longmult = (foldl1 ((+) . (10 *)) .) . (. digits) . polymul . digits
|
||||
longmult :: Integer -> Integer -> Integer
|
||||
longmult x y = foldl1 ((+) . (10 *)) (polymul (digits x) (digits y))
|
||||
|
||||
main :: IO ()
|
||||
main = print $ (2 ^ 64) `longmult` (2 ^ 64)
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
procedure main()
|
||||
write(2^64*2^64)
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue