Linear Congruences by moriA

m@main=f[-1..8^5]
f=(getLine>>=).g
g a[]=putStrLn(k a)>>m
g(m:s)c=f$m`lcm`h c:[n|n<-s,n`mod`h c==read[c!!4,c!!5]]
h=read.drop 11.init
k(a:b:_)=show b++" + "++show a++"k"
k _="no solutions"

Note that non-ascii characters in the above source code will be escaped (such as \x9f).

download

return to the top page