Linear Congruences by 51b

import std.stdio;void main(){for(int a,b=1,p,q,u,t,c,d,s;~scanf("x =%d%*s%d%[)
]",&p,&q,&s);s%3?a=!printf(b?&*"%d + %dk
":&*"no solutions
",a,b),b=1:0){for(c=u=b,d=q;c;d=t)t=c,c=d%c;for(b*=q/d;a>b?b*=0:a%q-p;)a+=u;}}

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

download

return to the top page