Algorithm of 10812 - Beat the Spread!

Problem Description Link
Algorithm:

To solve this problem you follow just simple trick.
 you get input a and b
sum=(a+b)/2;
diff=(a-b)/2;

if(sum+diff=a && sum-diff=b)
then print sum and diff
otherwise print impossible
image

No comments:

Post a Comment

Write your comment - Share Knowledge and Experience