## 10242 - Fourth Point !!

Moderator: Board moderators

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

### Go to...

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.
_.

mlvahe
New poster
Posts: 23
Joined: Wed Jul 30, 2003 6:54 am
Location: Yerevan, Armenia
_.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.

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

### Right.

Perhaps mlvahe. Might be some mistake if they left the empty line at the end. That's a sure WA for us Pascal users
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
_.

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

### 10242 Is this formula right?

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
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
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
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...........

someone pls explain this problem....no 10242

Code: Select all

``keep dreaming...``

mf
Guru
Posts: 1244
Joined: Mon Feb 28, 2005 4:51 am
Location: Zürich, Switzerland
Contact:
What exactly do you want to be explained?

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

newton
Experienced poster
Posts: 162
Joined: Thu Jul 13, 2006 7:07 am
Contact:

### Re: 10242 - Fourth Point!!

Why im getting WA?

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

### Re: 10242 - Fourth Point!!

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!!

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:

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!!

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!!

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!