10519 - !! Really Strange !!

All about problems in Volume 105. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

zyxw
New poster
Posts: 24
Joined: Sat Mar 22, 2008 5:49 am
Location: Chennai
Contact:

10519 - RTE

Post by zyxw »

I'm new to Java..
My code gets RTE.

Is my method of taking input wrong?
Please help :roll:

Code: Select all

cut after AC
Last edited by zyxw on Tue Nov 11, 2008 3:28 pm, edited 1 time in total.
I am not totally useless, because I can still be used as a bad example :P
DD
Experienced poster
Posts: 145
Joined: Thu Aug 14, 2003 8:42 am
Location: Mountain View, California
Contact:

Re: 10519 - Really Strange

Post by DD »

dust_cover wrote:can anybuddy tell me what should be the output for inout 0 & 1.....I am getting WA.
I used BigInt library
Also used the standard formula for the problem!

Thanx in advance
To dust_cover:

You should output 1 if input is 0, and 2 if input is 1.

Hope this can help you.
Have you ever...
  • Wanted to work at best companies?
  • Struggled with interview problems that could be solved in 15 minutes?
  • Wished you could study real-world problems?
If so, you need to read Elements of Programming Interviews.
zyxw
New poster
Posts: 24
Joined: Sat Mar 22, 2008 5:49 am
Location: Chennai
Contact:

Re: 10519 - Really Strange

Post by zyxw »

This is REALLY STRANGE :oops:

The code which i posted in my previous post got WA today!
I don't understand how RTE changed to WA..
Anyway after correcting the error, got AC :)
I am not totally useless, because I can still be used as a bad example :P
mak(cse_DU)
Learning poster
Posts: 72
Joined: Tue May 30, 2006 5:57 pm
Location: bangladesh

Re: 10519 Very Strange... Key formula...

Post by mak(cse_DU) »

soyoja wrote:I read previous article that the key formula for solving this problem is

"f(n) = n^2 - n + 2 ".

But I'm very anxious how can generate this formula....

Could anyone explain this principle?
I just count the number of intersection and add 2.
That means F(N)=number_Of_Intersection + 2;

How can we calculate number_Of_Intersection?
Just think that........
Using two circle we can make intersection.......
--------------------------------------------------------------------------
So select 2 circle from N circle= nC2.
Every two circle make 2 intersection.
so number_Of_Intersection=2 * nC2 .
F(N)=2* N*(N-1)/2 + 2
=>F(N) = N*(N-1)+2
=>F(N) = N*N - N + 2.

Special case:
0------------>1
Mak
Help me PLZ!!
plamplam
Experienced poster
Posts: 150
Joined: Fri May 06, 2011 11:37 am

Re: 10519 - Really Strange

Post by plamplam »

Nice problem but lame description. It took me a lot of time just to understand what the problem-setter was saying. I suggest this problem-setter guy needs to learn how to communicate properly.
Best Regards.
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson
uDebug
A great helper
Posts: 475
Joined: Tue Jul 24, 2012 4:23 pm

Re: 10519 - Really Strange

Post by uDebug »

Here's some input / output that I found useful during testing / debugging.

Input:

Code: Select all

0
1
4589723412211934134013
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
AC Output:

Code: Select all

1
2
21065561000606359857403149578459628309350158
999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002
Check input and AC output for over 7,500 problems on uDebug!

Find us on Facebook. Follow us on Twitter.
Post Reply

Return to “Volume 105 (10500-10599)”