Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- long long int cc = c; //saving the starting value of c
- c=c-a; //a has to be in c at least once
- while(c>0){ // we reduce c by a in each step until b divides c, which would mean we found
- if(c%b==0){ //solutions to c=xa+yb or until c becomes <=0
- y = (c/b); //evaluating y
- x = ((cc - c)/a); //evaluating x
- if(gcd(x,y)==1) //if it's correct, then it's possible, otherwise try other solutions
- return true;
- }
- c=c-a; //reduce c by a
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement