10242 - Fourth Point !!

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
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Go to...

Post by _.B._ » Thu Apr 15, 2004 5:13 am

Greetings!.
Go to:
http://online-judge.uva.es/board/viewtopic.php?t=5466
It might be of help for you.

P.S.: I used "double" and got AC in 0:00.002, then used "real" and got AC in 0:00.000. The problem says:
All coordinates are between -10000 and +10000.
So I believe that's why "real" is enough.
_.

User avatar
mlvahe
New poster
Posts: 23
Joined: Wed Jul 30, 2003 6:54 am
Location: Yerevan, Armenia

Post by mlvahe » Thu Apr 15, 2004 12:34 pm

_.B._ I really don't know why there are empty lines in the input.
The only idea I have is there is a blank line after the input.

User avatar
_.B._
Experienced poster
Posts: 160
Joined: Sat Feb 07, 2004 7:50 pm
Location: Venezuela
Contact:

Right.

Post by _.B._ » Thu Apr 15, 2004 10:34 pm

Perhaps mlvahe. Might be some mistake if they left the empty line at the end. That's a sure WA for us Pascal users :o
Still don't know why they don't use simple input, without tricks and whitspaces and empty lines... like I read in one post, they should do a problem of that kind, if they want to, but throw only good input.
Anyway, it was great you noticed it :D
_.

Morning
Experienced poster
Posts: 134
Joined: Fri Aug 01, 2003 2:18 pm
Location: Shanghai China

10242 Is this formula right?

Post by Morning » Mon Oct 04, 2004 7:55 pm

if i know (x0,y0),(x1,y1),(x2,y2) as three adjacent point of a parallelogram,and (x0,y0) belongs the 1st line,(x1,y1) is the link point of 1st line and 2nd line,(x2,y2) belongs the 2nd line.
can i calculate the 4th point (x3,y3) by

Code: Select all

x3 = x0 + x2 - x1
y3 = y0 + y2 - y1
???????
[cpp]
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
double x0,y0,x1,y1,x2,y2,x3,y3;
while(cin >> x0 >> y0 >> x1 >> y1 >> x1 >> y1 >> x2 >> y2)
{
x3 = x0 + x2 - x1;
y3 = y0 + y2 - y1;
printf("%.3lf %.3lf\n",x3,y3);
}
return 0;
}
[/cpp]
"Learning without thought is useless;thought without learning is dangerous."
"Hold what you really know and tell what you do not know -this will lead to knowledge."-Confucius

Eduard
Experienced poster
Posts: 183
Joined: Fri Sep 26, 2003 2:54 pm
Location: Armenia,Yerevan

Post by Eduard » Mon Oct 04, 2004 8:10 pm

Formula is right! But nobody tell you that in the input endpoints are given one after another in right form for example your programm can pase this input.

Code: Select all

1.000 0.000 3.500 3.500 3.500 3.500 0.000 1.000
But not this.

Code: Select all

1.000 0.000 3.500 3.500 0.000 1.000 3.500 3.500 
Hope it helps.
Eduard
someone who like to solve informatic problems.
http://acm.uva.es/cgi-bin/OnlineJudge?AuthorInfo:29650

Morning
Experienced poster
Posts: 134
Joined: Fri Aug 01, 2003 2:18 pm
Location: Shanghai China

Post by Morning » Mon Oct 04, 2004 8:29 pm

yeah ,u r right.thanks,buddy
"Learning without thought is useless;thought without learning is dangerous."
"Hold what you really know and tell what you do not know -this will lead to knowledge."-Confucius

kenneth
New poster
Posts: 24
Joined: Wed Mar 02, 2005 12:29 am

Post by kenneth » Tue Sep 13, 2005 8:30 am

Just a note that for C++ users, use double but NOT float

apurba
New poster
Posts: 42
Joined: Sun Oct 07, 2007 10:29 pm

anyone help to understand this problem...........

Post by apurba » Mon Jan 07, 2008 11:48 am



someone pls explain this problem....no 10242

thanks in advance........

Code: Select all

keep dreaming...

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:

Post by mf » Mon Jan 07, 2008 11:59 am

What exactly do you want to be explained?

If you don't understand the problem statement, get a dictionary.

User avatar
newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Location: Campus Area. Dhaka.Bangladesh
Contact:

Re: 10242 - Fourth Point!!

Post by newton » Tue Aug 26, 2008 6:25 pm

Why im getting WA?
Please help

Code: Select all

#include <cstdio>
#include <cmath>
#include <algorithm>
#define eps 1e-7

int main(){
	//freopen("in.txt","rt",stdin);
	double x1,y1,x2,y2,x3,y3,x4,y4;
	while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4) == 8){
		if(fabs(x2-x3) < eps && fabs(y2-y3) < eps){
			x3 = x4;
			y3 = y4;
		}
		printf("%.3lf %.3lf\n",x1+x3-x2,y1+y3-y2);
	}
	return 0;
}

Obaida
A great helper
Posts: 380
Joined: Wed Jan 16, 2008 6:51 am
Location: (BUBT) Dhaka,Bagladesh.

Re: 10242 - Fourth Point!!

Post by Obaida » Mon Feb 23, 2009 10:57 am

You should check which two points match and then go for the 4th point. :)
try_try_try_try_&&&_try@try.com
This may be the address of success.

talizmelf
New poster
Posts: 3
Joined: Thu Oct 15, 2009 5:54 am

Re: 10242 - Fourth Point!!

Post by talizmelf » Thu Oct 15, 2009 5:59 am

I checked wich two points match and I still get WA

Code: Select all

#include <iostream>
#include <cstdio>
using namespace std;

int main(){
	double ax1, ay1, ax2, ay2, bx1, by1, bx2, by2, x, y;
	while (!cin.eof()){
		cin >> ax1 >> ay1 >> ax2 >> ay2 >> bx1 >> by1 >> bx2 >> by2;
		if (ax1 == bx1 && ay1 == by1) {x = ax2+bx2-ax1; y = ay2+by2-ay1;}
		else if (ax1 == bx2 && ay1 == by2) {x = ax2+bx1-ax1; y = ay2+by1-ay1;}
		else if (ax2 == bx1 && ay2 == by1) {x = ax1+bx2-ax2; y = ay1+by2-ay2;}
		else {x = ax1+bx1-ax2; y = ay1+by1-ay2;}
		printf("%0.3f %0.3f\n", x, y);
	}
}
can anyone help?

sh415
New poster
Posts: 13
Joined: Fri Nov 13, 2009 9:31 am
Location: JU

Re:

Post by sh415 » Fri Oct 22, 2010 11:47 pm

Caesum wrote:you dont know for sure that (x2,y2) and (x3,y3) are the common point.
its an interesting problem......

here we are give the point of two connected side of a parallelogram.
so; actually we are given 3 points..................
we just have to find the fourth one........

suppose; we are given 1 2 3 2 points(1,2,3 repesents different identity )

here 4th point are same ( 1, 2, 3, 2) with 3 rd point. now we have to decide the 3 rd point from the condition and then calculate the fourth one which is unknown...................

we may have other input like 1 2 1 3 or 1 2 2 3...........................

live_lie
New poster
Posts: 19
Joined: Mon Nov 29, 2010 11:50 pm

Re: 10242 - Fourth Point!!

Post by live_lie » Tue Jun 21, 2011 7:17 pm

thank you keneth and obaida you helped me to get an AC.

brianfry713
Guru
Posts: 5947
Joined: Thu Sep 01, 2011 9:09 am
Location: San Jose, CA, USA

Re: 10242 - Fourth Point!!

Post by brianfry713 » Tue Dec 03, 2013 3:03 am

Input:

Code: Select all

0.000 1.000 0.000 0.000 0.000 1.000 1.000 1.000
0.000 1.000 0.000 0.000 1.000 1.000 0.000 1.000
0.000 0.000 0.000 1.000 0.000 1.000 1.000 1.000
0.000 0.000 0.000 1.000 1.000 1.000 0.000 1.000
Output should be:

Code: Select all

1.000 0.000
1.000 0.000
1.000 0.000
1.000 0.000
Check input and AC output for thousands of problems on uDebug!

Post Reply

Return to “Volume 102 (10200-10299)”