Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. long long int cc = c; //saving the starting value of c
  2. c=c-a; //a has to be in c at least once
  3. while(c>0){ // we reduce c by a in each step until b divides c, which would mean we found
  4. if(c%b==0){ //solutions to c=xa+yb or until c becomes <=0
  5. y = (c/b); //evaluating y
  6. x = ((cc - c)/a); //evaluating x
  7. if(gcd(x,y)==1) //if it's correct, then it's possible, otherwise try other solutions
  8. return true;
  9. }
  10. c=c-a; //reduce c by a
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement