11207  The easiest way
Moderator: Board moderators
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.
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
HomePage
wa in 0.061 s > AC
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
have do too:
0
000
input:
6 4
4 4
output:
1
thanks in advance...
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
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.

 Experienced poster
 Posts: 196
 Joined: Wed May 02, 2007 10:12 pm
 Location: Hungary, Pest county, Halasztelek
 Contact:
My program fail only for the following posted input:
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.
Code: Select all
3
1 4
2 6
2 7
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.

 Experienced poster
 Posts: 196
 Joined: Wed May 02, 2007 10:12 pm
 Location: Hungary, Pest county, Halasztelek
 Contact:
Invisible text follows (Spoiler):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.
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
Are you dreaming right now?
http://www.dreamviews.com
Re: 11207  The Easiest Way
Hello everybody!
Could you put more inputs here?
I tried all inputs posted here and the answers are equals.
thanks
Could you put more inputs here?
I tried all inputs posted here and the answers are equals.
thanks

 Learning poster
 Posts: 97
 Joined: Fri Aug 22, 2008 10:18 pm
 Location: CSE.SUST.SYLHET
Re: 11207  The Easiest Way
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

 New poster
 Posts: 2
 Joined: Tue Aug 09, 2011 7:19 pm
Re: 11207  The Easiest Way
// 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...
// 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...

 New poster
 Posts: 3
 Joined: Sun Mar 29, 2015 6:21 pm
Re:
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).jan_holmes wrote:I'm confuse about this test case. Can anyone explain it to me ? Thx...Try this case..
Code:
2
1 10000
10 10
0
My output is
Code:
2

 New poster
 Posts: 3
 Joined: Sun Mar 29, 2015 6:21 pm
Re: 11207  The Easiest Way
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?