You are not logged in. Please login at www.codechef.com to post your questions!

×

little elephant and music wrong answer

helo all, I am getting wrong answer in this question here my solution here is simple and close to the editorial the problem is easy . I tried large input and it works . if someone could tell me where I am wrong or give me a wrong test case it will be much appreciated , cheers.

asked 23 Apr '14, 09:47

muhammedabuali's gravatar image

0★muhammedabuali
711315
accept rate: 0%


@muhammedabuali
Your approach is correct.

This is the Accepted solution. I just changed some variable types to "long long int" and it was accepted.

If you have to multiply 2 numbers whose product cannot be stored in an int type variable, then the two numbers multiplied should also be "long long int".
For example:
if you have to perform c=a*b and a=10^9 and b=10, then a,b and c all should be "long long int" type.

link

answered 23 Apr '14, 12:10

roman28's gravatar image

4★roman28
1.6k71429
accept rate: 19%

edited 23 Apr '14, 12:11

The answer about c = a*b is not exact. Basically only c have to be long long, because a and b fits in int, but compiler have to know, that you really do not want int overflow, but long long calculation. You can achieve this by casting or multiplying by 1LL.

http://ideone.com/IxnN53

Of course having all as long long is the simple and safe approach.

Your link to ideone is not working for me, but you can link to your solution in practice section ;-)

(23 Apr '14, 13:37) betlista ♦♦3★

My bad!! I forgot to make my code public.

(23 Apr '14, 14:20) roman284★
1

No problem, secret is almost always better than public :-D

(23 Apr '14, 17:54) betlista ♦♦3★

sorry for the late reply . but that's an annoying issue thanks

(20 May '14, 00:39) muhammedabuali0★
toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:

×3,707
×1,901
×846
×543
×110

question asked: 23 Apr '14, 09:47

question was seen: 961 times

last updated: 20 May '14, 00:39