Problem Linkhttps://www.codechef.com/problems/EXOCODE5 Author:https://www.codechef.com/users/vivek96 DIFFICULTY:EasyMedium PREREQUISITESBigInteger,Basic Java Programming PROBLEM:Chef is a brave Warrior who with his group of young soldiers moves from one place to another to fight against his opponents. Before Fighting he just calculates two things,the difference between his soldier number and the type of opponent’s soldier number. From this difference and the opponent army soldier number type (even or odd number)?, he decides whether to fight or not? Print the difference and the type of opponent army soldier number! Chef ‘s opponent number is never greater than Chef number. Constraints:The numbers are less than 10^25 EXPLANATION:From the Question statement it is crystal clear that we have to find difference between chef army soldier number and opponent soldier number. Numbers are large so we have to use BigInteger Class(The java.math.BigInteger class provides operations analogues to all of Java's primitive integer operators and for all relevant methods from java.lang.Math.) Introduction to Big Integerhttps://goo.gl/WZis9f IN C/C++ http://codeforces.com/blog/entry/16380 Using BigInteger class function subtract we calculated the difference,then we have to check whether opponent soldier number is even or odd. (A number is said to be even number if it leaves no remainder when divided by 2. There is an alternative definition of even number and it is as a number having any number from 0, 2, 4, 6 and 8 at its ones place is an even number. Examples of even numbers are 12, 66, 456, 9900 and 12342 etc. An odd number leaves a remainder when it is divided by 2. All those numbers having any one from 1, 3, 5, 7 and 9 at their ones places are also called odd numbers.) So for Checking Whether number is even or odd we can use remainder function,so if number is even we have to print even else print odd AUTHOR'S AND TESTER'S SOLUTIONS: import java.util.Scanner; import java.math.BigInteger; class ChefBraveWarrior {
} edit1correction asked 15 Mar '17, 17:17
showing 5 of 7
show all

I need karma points to ask my first questions. Please upvote me!! answered 15 Mar '17, 20:03

A C++ implementation and explanation would be nice dear. Please consider adding it. :) answered 15 Mar '17, 18:11

The numbers in your test cases go up to 10^{24}. Check status code here and here. This is misleading because 10^{19} fits in
unsigned long long int
but a person using that would get WA. You should update either the test cases or the problem statement.Hey @meooow! Can you tell how did you find that the numbers in his test cases went upto 10^24??
I was surprised to get WA with
unsigned long long
so I made a few submissions that throw an exception if a specified limit is exceeded, and it turns out the max value is somewhere between 10^{23} and 10^{24}.Wow!! How did you made a guess that max value was between that range? I can understand the part where its greater than 10^20 (overflow in long long int) but how did you precisely found the limit?
Trial and error :P You can see the two submission links, the one with limit 10^{23} gives RE but 10^{24} is accepted. You can do a manual binary search to narrow it down further if you have nothing to do at the moment XD
LOL XDDDDDD. Oh God @meooow! You're just...oh my..."Trial and Error" FTW ....XDXDXD hahaha.
okay meoow,xDDDDD