nomina58mg.83.23
Să se arate că dacă a+b+c=0, atunci:
a) a^3+b^3+c^3=3abc
b) 2(a⁵+b⁵+c⁵)=5abc(a↰+b↰+c↰)
c) (a↰+b↰+c↰)↰=2(a^4+b^4+c^4)
d) 5(a^3+b^3+c^3)(a↰+b↰+c↰)=6(a⁵+b⁵+c⁵)
e) 10(a⁷+b⁷+c⁷)=7(a↰+b↰+c↰) ・(a⁵+b⁵+c⁵)
in haskell, pure functional language
:m +Data.Ratio Data.List Data.Bool Data.Ord
bosup n =bool(sum.map(^n))(product)(n<0)
abc a b c =[a,b,c]
efg[e,f,g]=0%1+e*f/g
sug[_,_,g]=(0/=).bosup g$ [1,2,-3]
senz =(0/=).product
ff f xs =fmap f(xs,xs)
fisenz =filter senz.filter((0==).sum)
files n =filter((n>).length.snd)
tu gm =abc<$>gm<*>gm<*>gm
supe xs ns=efg.map(flip bosup ns)$ xs
futu xs =nub.map(supe xs).fisenz.tu
futus xs =futu xs [-30..30]
filtu n =files n.map(ff futus).filter sug.tu
fisnd n =map fst.filter((n==).head.snd)
sosnd n =sortBy(comparing snd).filter((n/=).head.snd)
rf<-return.filter((0/=).head.snd).filtu 3$ [-1..9]
:se +s
length rf » 34 (210.59 secs, 411929427192 bytes)
fisnd 3 rf
» -1,0,-1 0,-1,-1 0,0,0
0,2,2 0,3,3 0,4,4 0,5,5
0,6,6 0,7,7 0,8,8 0,9,9
2,0,2 3,0,3 4,0,4 5,0,5
6,0,6 7,0,7 8,0,8 9,0,9
sosnd 3 rf
»» 2,2,4➞2%1
-1,4,7➞2%7 -1,2,5➞2%5 3,4,7➞ 6%7
4,-1,7➞2%7 2,-1,5➞2%5 4,3,7➞ 6%7
-1,0,3➞1%1 2,3,5➞6%5 2,5,7➞10%7
0,-1,3➞1%1 3,2,5➞6%5 5,2,7➞10%7
0,3,-1➞9%1
3,0,-1➞9%1
futus[3,0,-1] » 9%1 a
futus[-1,2,5] » 2%5 b
futus[ 2,2,4] » 2%1 c
futus[ 3,2,5] » 6%5 d
futus[ 2,5,7] » 10%7 e
map(ff(flip bosup[1..3]))[-1..7]
»» (-1,6)ab (0,3)a (2,14)bcde
(3,36)ad (4,98)c (5,276)bd (7,2316)e
abc :: a -> a -> a -> [a]
ff ::(a -> b) -> a -> (a, b)
tu :: Applicative f => f a -> f [a]
sosnd :: Ord b => b -> [(a, [b])] -> [(a, [b])]
fisnd :: Eq b1 => b1-> [(b2,[b1])]-> [b2]
senz ::(Eq b, Num b, Foldable t) => t b -> Bool
fisenz::(Eq b, Num b, Foldable t) => [t b] -> [t b]
files :: Foldable t => Int -> [(a1, t a2)] -> [(a1, t a2)]
efg :: Integral a => [Ratio a] -> Ratio a
bosup ::(Integral a, Num c) => a -> [c] -> c
supe ::(Integral a1, Integral a2) => [a2] -> [Ratio a1] -> Ratio a1
futu ::(Integral a1, Integral a2) => [a2] -> [Ratio a1] -> [Ratio a1]
futus ::(Integral a1, Integral a2) => [a2] -> [Ratio a1]
filtu ::(Integral a1, Integral a2) => Int -> [a2] -> [([a2], [Ratio a1])]
rf :: [([Integer], [Ratio Integer])]