October LunchTime UNofficial Editorials (First two problems) Revised

@taran_1407 but wouldn’t the calculator print exactly 09 only?

Which language you are talking about mate??

I work with java. Either share code link. :slight_smile:

Nope, It isn’t mentioned in problem but a calculator always print 9, not 09. You may try. :slight_smile:

Yes, but since the calculator is faulty and skips carry i thought it should print 5555+5555 as 0000.
Thanks for replying though.

No problem at all.

By the way, the calculator isn’t that faulty :smiley:

1 Like

Here is my sol:CodeChef: Practical coding for everyone

The logic of your code isn’t clear to me. Can you elaborate??

Agreed

That ought to be the case, but i thought of real life calculators, which never print 0000. Maybe the author’s calculator wasn’t that faulty to print 0000. :smiley:

3 Likes

Mate, in his solution, that matters not.

Because he used the condition a>0 || b > 0

If one of them is zero, it will be automatically ignored.

for each i erased character at that place…

And checked the string so formed is divisble by 6 or not

check condition in O(1)

condition:

1.check even or not

2.if yes check (sum-a[i])%3 or not

I think it’s just because erase giving Tle

Possible XD. Imagine my reaction when I opened comment section after 20min only to realzie that leading zeroes are giving WA. I was like, “… (xinfinity)XDXD”

2 Likes

Your code can only delete 3,6 and 9 from given number due to line

if(p%3==0)

Further, no need to check sum%3==0

Simply check (sum-d)%3==0 where d is the deleted digit.

@taran_1407 plzz join this group,it gonna helpful for us!!

As far as i know about c++, String s = p itself takes Linear time, making your solution time out.

How Come??

Surely you can ask anything here mate…

Happens Mate…

I see you haven’t participated in lunchtime…

Ask away mate…

I did use two loops but not two nested loops. There’s a difference. Nested loop is loop within a loop, which i haven’t used and you have.

That’s what that make the difference. :slight_smile:

@taran_1407 the very first solution that passed is O(N^2)! Can you please look at his code and please comment that whether the test cases are weak or he has made some optimization ?

link to the code : CodeChef: Practical coding for everyone