Wednesday, October 8, 2014

ACM 1349. Farm / Ферма

 This task is very easy if you know the Fermat's Last Theorem, it states that if we have an expression a^n+b^n=c^n and if n is greater than 2 than there is no triple of positive integers a b c that satisfies this equation. In case of 1 the answer is 1 2 3 in case of 2 it is any Pythagorean triple such as 3 4 5 and in all other cases the answer is -1.


       FULL SOURCE CODE




No comments:

Post a Comment