We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
- Prepare
- Mathematics
- Fundamentals
- Die Hard 3
- Discussions
Die Hard 3
Die Hard 3
Sort by
recency
|
61 Discussions
|
Please Login in order to post a comment
// char* solve(int a, int b, int c) { int c1=hcf(a,b); if(c<=Math.max(a,b)&&c%c1==0) return "YES"; else return "NO";
} public static int hcf(int n1, int n2) { if (n2 != 0) return hcf(n2, n1 % n2); else return n1; } }
My Python3 solution
I first solved this problem with backtracking (which works great for games, or procedures with limited next steps available), but using the gcd was a lot simpler - I didn't think about it for a while, though. So there are a few ways to solve this problem!
I cannot understand the question,
why he made it so complex, why not just pour 4 galon at the begin in a, then it is done, a = 4, b =