Linear Congruences by ozy4dm

a,b,c;s;i,k;f(x,y){i=y?f(y,x%y):b/x;}main(d,v){for(;gets(v);d=s?i*d:!!printf(c-d?"%d + %dk\n":"no solutions\n",c,d,k=0))for(s=~sscanf(v,"x =%d%*s%d",&a,&b),c=k;k<f(d,b)*d&&k%d-c|k%b-a;++k);}

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

download

return to the top page