CGL_1_A Projection
Table of contents
# Problem
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A
# Explanation
Refer the link below for algorithm
# Solution
void project(Vector2 start_, Vector2 end_, Vector2 p) {
Vector2 v = end_ - start_;
Vector2 op = start_ + v * (v.dot(p - start_) / v.norm());
cout << op.x << ' ' << op.y << endl;
}
#define MAX_N 1001
Int N;
Vector2 start_, end_, p;
void input() {
cin >> start_ >> end_ >> N;
while (cin >> p) {
project(start_, end_, p);
}
}
int main() {
cout.precision(15);
input();
}
Shun
Remote freelancer. A web and mobile application enginner.
Traveling around the world based on East Asia.
I'm looking forward to your job offers from all over the world!