October LunchTime UNofficial Editorials (First two problems) Revised

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

Hey @taran_1407, did you solve the third problem i.e. Optimal Subset?
I have a conventional O(n^2) DP approach and optimizing it seems way too difficult to me and I canā€™t even think of any other way to approach that problem too.
Any suggestions on that?

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,

maximum value of n is 100000 so it remain in the int range so it is not the reason of getting RE(NZEC) . So why i am getting RE(NZEC).please help!
thank you.

Loving your explanations dude.

well done C.A :stuck_out_tongue: as your institute suggests

code , can you please help me out why it is giving wrong answer.

@taran_1407
I am getting run-time error. I tried too much to find where i am getting this but failed.
please help me.
this is my codeā€“>
https://www.codechef.com/viewsolution/15994545
thank you

Probably weak test casesā€¦

N is the number of digits in given problemā€¦
Means the number can be upto 10^(10^5), way beyond int and long range

Mate

Try following tesr case

1

10000200000000000

Can anyone give me a test case where my code fails? Itā€™s working well for all the test cases I checked.

PLEASE HELP ME!!!

Iā€™m storing the digits in an array from oneā€™s place. Then I am iterating through all the digits and finding the new number by removing that particular digit. Now, Iā€™m checking whether it is divisible by 6 or not and if it is then I check whether it is largest number possible which I initially set to -1. At last Iā€™m printing the new number with k-1 digits where k is the total number of digits in the initial number. Leading zeros will be printed since I used %0*d and passed k-1 and maxnum to it. LINK:-My Solution

Thanksā€¦

PS: I am a first year student, not yet CA. Long way to go!!

Mate, You cannot take a number with 10^5 digits in int data type. You have to input it as a string.

Try following test case.

1

10000200000000000

Second thing, Your solution try to delete one digit, check the resultant number. This way, Your solution has time complexity O(N^2), which wonā€™t even pass the time limit for number of digits upto 10^3.