Advertisement
Guest User

save the prisoner

a guest
Dec 12th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.21 KB | None | 0 0
  1. static int saveThePrisoner(int p, int c, int s) {
  2.         if (p>c+s)
  3.             return (c+s)-1;            
  4.         int res=c%p;
  5.        
  6.         if (s!=0)
  7.             res+=s-1;
  8.  
  9.         return res;
  10.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement