October LunchTime UNofficial Editorials (First two problems) Revised

@soham1234 CodeChef: Practical coding for everyone

just remove the line where you have checked the value of p and AC :slight_smile:

the idea is that when you get the value lesser, in the position nearer to the units place it will lead to better solution than that in the higher digits !

1 Like

Hey @shivam2296 ur code showing wrong for a.length<b.length

Example:
input:

2

11 1145

12 13456

output:

-)

)9

plzz join fb group:CODECHEF (practise) | Facebook

you are getting -1 for 66666666666

Your Code gives wrong input for

1

99999999 99999999

output:
88888880

But Unable to figure out the exact reason for WA

@taran_1407 @vijju check out this code why showing wrong

it’s showing Acess Denied :frowning:

Thats because of pow10 function, which stores result in double. Due to precision loss of ~{10}^{-8}, it shows deviation at large values.

1 Like

Ur code printing leading Zeroes!!

Mate, you are complicating your life a lot by using that vector V. Simply check for digit remainder 3 during a loop, check if sum%3 == d%3. It will give same reaults.

Refer to my implementation and feep free to ask anythibg… :slight_smile:

A must know thing for python coders. When dealing with large number, Even basic arithmetic operations like remainder cost time proportional to number of digits, making your solution O(N^2).

Feel free to ask anything…

Mate, you cannot take a number greater than or equal to 2^31 or smaller than -2^31 as int in java.

Take input as

String p = obj.next();

Feel free to ask anything… :slight_smile:

Your scanner gives element not found exception by scanner because it cannot find any integer in input file. All number this large will be treated as string input by scanner

Well, i certainly can’t find any test cases. First thing, keep your code clean, it will help degugging. Second thing, you haven’t added last digit to sum after testing for impossible cases.

Maybe you can ask problem setters for this… They can provide much better test cases then i can. :slight_smile:

by doing these it again show RE(NZEC)
and i doesn’t understand
Your scanner gives element not found exception by scanner because it cannot find any integer in input file. All number this large will be treated as string input by scanner

@vparas , please read about java errors on input, limit of int and long data types.

can u tell me the solution for 102 and 100

I got only 40 points in Optimal Subset using an observation. Just waiting for official editorial to find out whether its correct or not. :smiley:

thanks mate, but loop will traverse at max six time because it is traversing digits. So how can it be TLE… I just can’t understand.

How come loop will transverse 6 times only??

Loop will transverse like 10^6 times as i know,