10213 - How Many Pieces of Land ?

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

Moderator: Board moderators

User avatar
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

ACC --> sample I/O

Post by Sedefcho » Sun Mar 13, 2005 7:34 pm

I finally got ACC on this problem. The problem was in my archive
for quite some time and finally I found some time to get
back to it.

Here is some sample I/O for anyone who might be interested.


INPUT

Code: Select all

18
0 
1 
54 
12575 
312544
808080777 
110010 
99999
878787878
1112143 
234000243
999999999
777777777
101010101
1000000000 
2000000000 
1234567890
2147483647

OUTPUT

Code: Select all

1
1
317683
1041390301833851
397580508821554746073
17766744538362351421688193776113027
6102302473357942756
4166250019582975003
24849919480110185721478177782865879
63742478475498293889839
124926329720184395503853225251864
41666666250000001958333329750000003
15247929506896815534083978943771277
4337584555967507575973509760476
41666666416666667624999999250000001
666666664666666670499999998500000001
96794050695522260242568330014498846
886151993063477126682488902248300547

Antonio Ocampo
Experienced poster
Posts: 131
Joined: Sat Jul 17, 2004 4:09 am
Location: Lima, Per

Post by Antonio Ocampo » Sun Apr 17, 2005 3:26 am

Well I got this output:

Code: Select all

1
1
317683
1041390301833851
397580508821554746073
17766744538362351421688193776113027
6102857182742934706
4166250019582975003
24849919480110185721478177782865879
63742478475498293889839
124926329720184395503853225251864
41666666250000001958333329750000003
15247929506896815534083978943771277
4337584555967507575973509760476
41666666833333332208333340083333334
666666667999999995500000013500000001
96794051479554078646053958357844896
886151993063477126682488902248300547
I don't know my mistake.

Please help me :lol:

User avatar
Sedefcho
A great helper
Posts: 374
Joined: Sun Jan 16, 2005 10:18 pm
Location: Bulgaria

Post by Sedefcho » Sun Apr 17, 2005 4:07 pm

Antonio,

You have different output than mine for
these inputs ( see the 4th, 3rd and 2nd LAST
lines from my input ).

Code: Select all

1000000000 
2000000000 
1234567890
I suggest you debug step-by-step
your program for these inputs.

And see
1) if something unusual happens while
your code gets executed
2) where exactly in your code this happens


The interesting thing is that the numbers in your output
begin with same digits as my output numbers but at some
moment a mismatch starts. You should check why is that.

Antonio Ocampo
Experienced poster
Posts: 131
Joined: Sat Jul 17, 2004 4:09 am
Location: Lima, Per

Post by Antonio Ocampo » Sun May 15, 2005 11:20 pm

Hi Sedefcho

It was a mistake in my bigint class :oops: At last it is fixed.

Thanks for your help

Greetings

Hector_Hsu
New poster
Posts: 13
Joined: Thu May 26, 2005 1:16 pm

Post by Hector_Hsu » Wed Jul 06, 2005 5:07 pm

Just

Ans = 1 + C(n,2) + C(n,4)

-> 1 + n*(n-1)/2 + n*(n-1)*(n-2)*(n-3)/24

------

We can observe and get it.

When n = 1 , ans = 1;
1 is the original area.

When n = 2 , ans = 2;
We have two points so get 1 line.Just add 1 more area.

When n = 3 , ans = 4;
We have three points so get 3 lines,Just add 3 more areas.

When n = 4 , ans = 8;
We have four points so get 6(C(4,2)) lines, Just add 6 more areas.
And there are two lines intersecting to form a new point in the middle.
Just Add another one area.

So we calculate the areas :

Ans = Original Area + lines + points made from lines

= 1 + C(n,2) + C(n,4)

User avatar
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am
Contact:

10213

Post by Rocky » Thu Sep 08, 2005 12:22 pm

I Got Wrong Answer In 10213(HOW MANY PEICE OF LAND).
Can Any Body Help Me By Giving Some I/o For This Problem

Help Me Please....

THANK"S IN ADVANCE
Rocky

User avatar
Rocky
Experienced poster
Posts: 124
Joined: Thu Oct 14, 2004 9:05 am
Contact:

acc at last

Post by Rocky » Tue Sep 13, 2005 9:08 am

Ah.. Simple Mistake I got Acc at least

Rocky

898989
Learning poster
Posts: 83
Joined: Wed Feb 01, 2006 12:59 pm
Location: (Fci-cu) Egypt
Contact:

10213 need answers to test cases

Post by 898989 » Fri Aug 04, 2006 11:02 pm

Pleases can any one give me answers to the next cases

Code: Select all

0
1
5
7
10
100
10000
124
21533
456
79888
1048576
2147483647
Sleep enough after death, it is the time to work.
Mostafa Saad

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: 10213 need answers to test cases

Post by Martin Macko » Thu Aug 24, 2006 5:37 am

898989 wrote:Pleases can any one give me answers to the next cases

Code: Select all

0
1
5
7
10
100
10000
124
21533
456
79888
1048576
2147483647
My AC's output:

Code: Select all

1
1
16
57
256
3926176
416416762492501
9388878
8955419035380574
1778051731
1697001927971339669
50371620921287095091201
886151993063477126682488902248300547

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Re: 10213 need answers to test cases

Post by Martin Macko » Thu Aug 24, 2006 5:38 am

And btw, there is already a thread on this problem. If there is a thread on a particular problem, please, use it to post your question and do not create a new one. (see http://online-judge.uva.es/board/viewtopic.php?t=3196)
forum 'Volume CII' description wrote:All about problems in Volume CII. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

User avatar
Martin Macko
A great helper
Posts: 481
Joined: Sun Jun 19, 2005 1:18 am
Location: European Union (Slovak Republic)

Post by Martin Macko » Thu Aug 24, 2006 5:46 am

Here you can find some more info on this sequence: Sloane's A000127.

hridoy
New poster
Posts: 21
Joined: Tue May 08, 2007 10:30 am
Location: Dhaka
Contact:

acm-10213

Post by hridoy » Mon Dec 03, 2007 8:42 pm

can anyone please tell me what is the prob in my following code>
what data type I should use?
#include<stdio.h>

long long f(long long n)
{
long long x=1,z,y=0;
if(n>3)
x=n*(n-1)*(n-2)*(n-3);
z=(x/24);
if(n>1)
y=((n*(n-1))/2);
return (y+z+1);
}

main()
{
long long a[3500],b[3500],s,n;
int i;
scanf("%lld",&s);

for(i=0;i<s;i++)
scanf("%lld",&a);

for(i=0;i<s;i++)
b=f(a);

for(i=0;i<s;i++)
printf("%lld\n",b);
}

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Tue Dec 04, 2007 5:25 pm

'long long' is not enough. You should use bigint calculations for this problem.
Ami ekhono shopno dekhi...
HomePage

hridoy
New poster
Posts: 21
Joined: Tue May 08, 2007 10:30 am
Location: Dhaka
Contact:

acm-10213

Post by hridoy » Tue Dec 04, 2007 8:34 pm

How can I use Bigint in C++?

Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan » Tue Dec 04, 2007 8:52 pm

Design your own Bigint class. Or you can collect it from other source. But better to make your own.
Ami ekhono shopno dekhi...
HomePage

Post Reply

Return to “Volume 102 (10200-10299)”