Note: x is probably not the solution, if there is no solution, is given no prompt solutions
CodePudding user response:
Not told you thinking?X=a=I + n * m * j + b
Launch
J=n * m * I + (a - b)
Launch
J=(m * I + (a - b))/n
Because I and j is an integer (m * I + (a - b)) must can ensure j can be divided exactly by n is integer
So, I have been cycle to a maximum of integer from 0, see if you can have a meet the conditions of I, find I is a solution, otherwise it is no solution
int mian () {
Int a, b, m, n, I;
The scanf (" % d % d % d % d ", & amp; M, & amp; N, & amp; A, & amp; B);
for (i=0; ; I++) {
If (i<0 {
Printf (" no solution ");
break;//I turned negative seams show unanswered
}
Else if ((m * I + a - b) % n==0) {
Printf (" has a solution: x=% d ", m * I + a);
break;
}
}
return 0;
}
CodePudding user response:
Simple and crude, only supplies the reference:# include & lt; stdio.h>
Int main (void)
{
Unsigned int a, b, m, n, x.
The scanf (" % d % d % d % d ", & amp; M, & amp; N, & amp; A, & amp; B);
X=1;
While (x)
{
If (m=(x %=a) & amp; & (x % n==b))
{
Printf (" has a solution: x=% u ", x);
return 0;
}
x++;
}
Printf (" no solution ");
return 1;
}
CodePudding user response:
Because you have the wrong ah, ha ha ha haCodePudding user response:
The