Linear Congruences by 51b

a,p,q,t,u;char s[9];f(c,d){!c?t=d:f(d%c,c);}main(b){for(;gets(s);)for(p=atoi(s+3),f(u=b,q=atoi(s+11)),b=!*s?a=!printf(b?"%d + %dk\n":"no solutions\n",a,b),1:q/t*b;*s?a>b?b=0:a%q-p:0;)a+=u;}

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

download

return to the top page