11207 - The easiest way

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

Moderator: Board moderators

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

Post by Jan » Thu Jun 07, 2007 1:15 pm

Warning : Spoiler Ahead...

Suppose the dimension is 'a x b' and a<=b.
Now, we have two options.

1. We can make an 'a x a' square (since a<=b). And after dividing it into four parts, the length of a square becomes a/2.

2.
i) if(b>=a*4) then we can make four 'a x a' squares. And so, the length of a square is a.
ii) if(b<a*4) then we can make four 'b/4 x b/4' squares. And so, the length of a square is b/4.

Finally, we have to find maximum length from these two options.
Hope it helps.
Ami ekhono shopno dekhi...
HomePage

adelar
New poster
Posts: 35
Joined: Wed May 02, 2007 11:48 pm
Location: Brasil

wa in 0.061 s ---> AC

Post by adelar » Fri Jun 08, 2007 5:28 pm

Hi people,
to all inputs in the board my code get ac... but I am with wa in 0.061 s
Something have a critic input to this problem?
Code AC :D
have do too:
0
000

input:
6 4
4 4

output:
1

thanks in advance...
Last edited by adelar on Mon Jun 11, 2007 3:30 pm, edited 2 times in total.

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

Post by Jan » Sat Jun 09, 2007 1:14 am

Read my previous post. It will help you.
Ami ekhono shopno dekhi...
HomePage

Robert Gerbicz
Experienced poster
Posts: 196
Joined: Wed May 02, 2007 10:12 pm
Location: Hungary, Pest county, Halasztelek
Contact:

Post by Robert Gerbicz » Sat Jul 07, 2007 4:34 pm

My program fail only for the following posted input:

Code: Select all

3
1 4
2 6
2 7
For this the posted output is 3. Why isn't 1 ?

For all three rectangles I think the biggest is 4 birds of 1x1 squares. Larger is impossible because 4*2^2=16 is bigger than the rectangle's area.

hamedv
Learning poster
Posts: 98
Joined: Mon May 07, 2007 8:30 am

Post by hamedv » Sat Jul 07, 2007 4:42 pm

the largest square for
2 7
is
1.75

Robert Gerbicz
Experienced poster
Posts: 196
Joined: Wed May 02, 2007 10:12 pm
Location: Hungary, Pest county, Halasztelek
Contact:

Post by Robert Gerbicz » Sat Jul 07, 2007 5:00 pm

hamedv wrote:the largest square for
2 7
is
1.75
Thanks! Now I got AC. I thought that all size of the birds are integers.

sakhassan
Experienced poster
Posts: 105
Joined: Sat Mar 11, 2006 9:42 am
Location: cse,DU

Post by sakhassan » Sat Sep 01, 2007 2:11 pm

I didn't get the idea yet.... Can anyone help me out?

Thanks in advanced
Time that gone is gone forever ...

User avatar
andmej
Experienced poster
Posts: 158
Joined: Sun Feb 04, 2007 7:45 pm
Location: Medellin, Colombia

Post by andmej » Mon Jan 14, 2008 4:58 pm

Jan wrote:Warning : Spoiler Ahead...

Suppose the dimension is 'a x b' and a<=b.
Now, we have two options.

1. We can make an 'a x a' square (since a<=b). And after dividing it into four parts, the length of a square becomes a/2.

2.
i) if(b>=a*4) then we can make four 'a x a' squares. And so, the length of a square is a.
ii) if(b<a*4) then we can make four 'b/4 x b/4' squares. And so, the length of a square is b/4.

Finally, we have to find maximum length from these two options.
Hope it helps.
Invisible text follows (Spoiler):

Suppose the dimension is 'a x b' and a<=b.

Your way seemed a little over complicated for me. It was easier to think it this way:

The maximum side length given a and b will be MAX( MIN(a, b/4), MIN(a/2, b/2) )
Runtime errors in Pascal are reported as Wrong Answers by the online judge. Be careful.

Are you dreaming right now?
http://www.dreamviews.com

Pedro
New poster
Posts: 5
Joined: Fri Jul 20, 2007 5:18 pm

Re: 11207 - The Easiest Way

Post by Pedro » Wed Apr 22, 2009 3:35 am

Hello everybody!

Could you put more inputs here?
I tried all inputs posted here and the answers are equals.

thanks

saiful_sust
Learning poster
Posts: 97
Joined: Fri Aug 22, 2008 10:18 pm
Location: CSE.SUST.SYLHET

Re: 11207 - The Easiest Way

Post by saiful_sust » Mon Jun 01, 2009 9:44 pm

HELLO Pedro

Here r some test cases:
I think this will help u....
INPUT:

Code: Select all

3
11 20000
40 1
12 32167
3
140 12200
122 14000
100 17011
2
120 170213
71 500011
0

OUTPUT:

Code: Select all

3
1
1

tamjidahmed
New poster
Posts: 2
Joined: Tue Aug 09, 2011 7:19 pm

Re: 11207 - The Easiest Way

Post by tamjidahmed » Sat Oct 15, 2011 7:06 pm

// HI I am tring this problem for 4 daye.....
// can anybody help me...:(



#include<stdio.h>
int main()
{
long long pop,i,ans=0;
double length,wide,temp,reqlength,maxwide;
while(scanf("%lld",&pop)==1)

{
if(pop==0) break;
ans=0;
maxwide=0;
reqlength=0;
for(i=1; i<=pop; i++)
{
scanf("%lf %lf",&wide,&length);
if(length<wide)
{
temp=length;
length=wide ;
wide=temp;
}
if(length==wide)
{
wide=wide/2;
reqlength=length*2;
}
else if(length>=wide*4)
{
wide=wide;
reqlength=wide*4;

}
else
{
if((wide/2)>(length/4))
{
wide=wide/2;
reqlength=wide*2;
}
else
{


wide=length/4;
reqlength=wide*4;
}
}
if(wide>=maxwide)
{

if(wide>maxwide)
{
ans=i;

}
else if(wide==maxwide && length<reqlength)
{
ans=i;
}
maxwide=wide;

}
}
printf("%lld\n",ans);
}

}

Thanks in advance... :D

robertocsa
New poster
Posts: 3
Joined: Sun Mar 29, 2015 6:21 pm

Re:

Post by robertocsa » Thu Apr 02, 2015 6:38 am

jan_holmes wrote:
Try this case..

Code:
2
1 10000
10 10
0


My output is

Code:
2
I'm confuse about this test case. Can anyone explain it to me ? Thx...
The first has one side too small. So the max side of each of the four squares of this line would be 1 (the width of the minor side in a longside cutted paper). For the second line, the result would be 5 (half of the side in a cross cutted paper).

robertocsa
New poster
Posts: 3
Joined: Sun Mar 29, 2015 6:21 pm

Re: 11207 - The Easiest Way

Post by robertocsa » Thu Apr 02, 2015 6:43 am

saiful_sust wrote:
HELLO Pedro

Here r some test cases:
I think this will help u....
INPUT:

Code: Select all

3
11 20000
40 1
12 32167
3
140 12200
122 14000
100 17011
2
120 170213
71 500011
0

OUTPUT:

Code: Select all

3
1
1

My replies are all being the same. I have already tested in others sites (toolkit etc). I am receiving Wrong Answer. I suppose that there is some "formating bug" in my code. Is there any special way to format it?

Post Reply

Return to “Volume 112 (11200-11299)”