寒假第一周:几何

  • POJ 2318 TOYS
  • POJ 2398 Toy Storage(叉积判断左右+二分)
  • POJ 3304 Segments(思维)
  • POJ 1269 Intersecting Lines
  • POJ 1556 The Doors(判断线段相交+最短路径)
  • POJ 1066 Treasure Hunt
  • POJ 1696 Space Ant(极角排序)
  • POJ 3347 Kadj Squares(扩大数据避免小数)
  • POJ 2826 An Easy Problem?!(大力出奇迹?)
  • POJ 3449 Geometric Shapes(非常恶心的读入)
  • POJ 1584 A Round Peg in a Ground Hole(凸包+点线圆的相对关系)
  • POJ 2074 Line of Sight(平面视线问题)

POJ 2318 TOYS

题意: 给定一个矩形区域,再给 n n n 个隔板(保证隔板相互之间交叉),现在有 m m m 个玩具(用二维坐标表示,保证不会超出边界),要求 n n n 个挡板划分出的 n + 1 n + 1 n+1 个区域中各有多少个玩具。

思路: 简单处理一下,用叉积来判断该点在直线的左边还是右边。

注意:在用叉积判断左右的时候要先确保,所有直线的起始点和终点的方向大致一样,例如都是下往上,否则判断结果会不同

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-8;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}
struct Point {double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const{return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const { //小在前return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}Point operator*(const double& k) const {return Point(k * x, k * y);}Point operator/(const double& k) const {return Point(x / k, y / k);}double operator^(const Point& b) const { //叉积return x * b.y - y * b.x;}double operator*(const Point& b) const {return x * b.x + y * b.y;}double len() {  //长度return sqrt(x * x + y * y);
//        return hypot(x, y);}double len2() {  //长度的平方return x * x + y * y;}double dis(Point p) { //两点距离return hypot(x - p.x, y - p.y);  //hypot是计算斜边长用的
//        return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));}double dis2(Point p) { //两点距离的平方return pow(x - p.x, 2.0) + pow(y - p.y, 2.0);}double rad(Point a, Point b) { //atan2(y, x),表示(x,y)在的角度(-pi,pi];Point p = *this;return fabs(atan2(fabs((a - p) ^ (b - p)), (a - p) * (b - p)));//角P的夹角}Point trunc(double r) { //转换为长度为r的向量,零向量除外double l = len();if (!dcmp(l)) return *this;r /= l;return Point(x * r, y * r);}Point rotleft() { //逆时针旋转90度return Point(-y, x);}Point rotright() { //顺时针旋转90度return Point(y, -x);}Point Rotate(Point p, double angle) {Point v = (*this) - p;double c = cos(angle), s = sin(angle);return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);}
};
struct Line {Point s, e;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}bool operator==(const Line& v) const {return (s == v.s) && (e == v.e);}Line(Point p, double angle) { //需要保证angle在[0, pi)s = p;if (dcmp(angle - pi / 2.0) == 0) {e = (s + Point(0, 1));}else {e = (s + Point(1, tan(angle)));}}Line(double a, double b, double c) { //ax + by + c = 0 一般式if (dcmp(a) == 0) {s = Point(0, -c / b);e = Point(1, -c / b);}else if (dcmp(b == 0)) {s = Point(-c / a, 0);e = Point(-c / a, 1);}else {s = Point(0, -c / b);e = Point(1, (-c - a) / b);}}void input() {s.input(); e.input();}void adjust() {if (e < s) swap(s, e);}double length() {return s.dis(e);}double angle() { //斜率,保证在[0, pi)double k = atan2(e.y - s.y, e.x - s.x);if (dcmp(k) < 0) k += pi;if (dcmp(k - pi) == 0) k -= pi;return k;}int relation(Point p) {int c = dcmp((p - s) ^ (e - s));if (c < 0) return 1; //在直线左侧else if (c > 0) return 2; //在直线右侧else return 3; //在直线上}bool pointonseg(Point p) { //点在线段上的判断(<=0表示包括端点)return dcmp((p - s) ^ (e - s)) == 0 && dcmp((p - s) * (p - e)) <= 0;}bool parallel(Line v) { //判断两向量平行return dcmp((e - s) ^ (v.e - v.s)) == 0;}double disPointToLine(Point p) { //点到直线的距离return fabs((p - s) ^ (e - s) / length());}double disPointToSeg(Point p) {  //点到线段的距离if (dcmp((p - s) * (e - s)) < 0 || dcmp((p - e) * (s - e)) < 0)return min(p.dis(s), p.dis(e));return disPointToLine(p);}
};
Line li[5005];
Point p[5005];
int main() {int n, m;while (scanf("%d", &n)) {if (n == 0) break;Point a, b;scanf("%d", &m);a.input(); b.input(); //a为左上角,b为右下角li[0].s = Point(a.x, b.y);li[0].e = Point(a.x, a.y);for (int i = 1; i <= n; i++) {int u, v;scanf("%d%d", &u, &v);li[i].e = Point(u, a.y);li[i].s = Point(v, b.y);}li[n + 1].s = Point(b.x, b.y);li[n + 1].e = Point(b.x, a.y);for (int i = 1; i <= m; i++) {p[i].input();}vector<int> pos(n + 2, 0);for (int i = 1; i <= m; i++) {for (int j = 0; j <= n; j++) {int d1 = li[j].relation(p[i]);int d2 = li[j + 1].relation(p[i]);if (d1 != d2) {pos[j]++;break;}}}for (int i = 0; i <= n; i++) {printf("%d: %d\n", i, pos[i]);}printf("\n");}return 0;
}

POJ 2398 Toy Storage(叉积判断左右+二分)

题意: 和上题差不多,但是是挡板是乱序输入的,还有OJ上的样例是错的。。。。。

思路: 因为和上题大致一样,换了一种思路,二分,利用叉积来做判断,需要注意的点和上题一致,也是要将线段的起点和重点的方向统一,不然无法用叉积判断是否在一边

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-8;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}
struct Point {double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const{return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const { //小在前return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}Point operator*(const double& k) const {return Point(k * x, k * y);}Point operator/(const double& k) const {return Point(x / k, y / k);}double operator^(const Point& b) const { //叉积return x * b.y - y * b.x;}double operator*(const Point& b) const {return x * b.x + y * b.y;}double len() {  //长度return sqrt(x * x + y * y);
//        return hypot(x, y);}double len2() {  //长度的平方return x * x + y * y;}double dis(Point p) { //两点距离return hypot(x - p.x, y - p.y);  //hypot是计算斜边长用的
//        return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));}
};
struct Line {Point s, e;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}bool operator==(const Line& v) const {return (s == v.s) && (e == v.e);}int relation(Point p) {int c = dcmp((p - s) ^ (e - s));if (c < 0) return 1; //在直线左侧else if (c > 0) return 2; //在直线右侧else return 3; //在直线上}
};
Line li[5005];
Point p[5005];
bool cmp(const Line& v1, const Line& v2) {if (v1.s.x == v2.s.x) return v1.e.x < v2.e.x;return v1.s.x < v2.s.x;
}
int main() {int n, m;while (scanf("%d", &n) && n) {scanf("%d", &m);Point p1, p2;p1.input(); p2.input(); //p1是左上角,p2是右下角for (int i = 0; i < n; i++) {int u, v;scanf("%d%d", &u, &v);li[i] = Line(Point(v, p2.y), Point(u, p1.y));}sort(li, li + n, cmp);
//        li[n] = Line(Point(p2.x, p2.y), Point(p2.x, p1.y));
//        printf("-------\n");
//        for (int i = 0; i <= n; i++) {//            printf("%.2f %.2f\n", li[i].s.x, li[i].e.x);
//        }
//        printf("-------\n");vector<int> pos(n + 1, 0);for (int i = 1; i <= m; i++) {p[i].input();int l = 0, r = n;while (r > l) {int mid = (l + r) >> 1;if (((p[i] - li[mid].s) ^ (li[mid].e - li[mid].s)) < 0)r = mid;else l = mid + 1;}pos[r]++;}
//        for (int i = 0; i <= n; i++) {//            printf("%d: %d\n", i, pos[i]);
//        }vector<int> ans(m + 1);for (int i = 0; i <= n; i++) {if (pos[i]) ans[pos[i]]++;}printf("Box\n");for (int i = 1; i <= m; i++) {if (ans[i])printf("%d: %d\n", i, ans[i]);}}return 0;
}

POJ 3304 Segments(思维)

题意:

题目大意:给n条线段,求是否存在一条直线,将所有线段投影到上面,使得所有投影至少交于一点。

思路: 这题是看题解的,刚开始想到与端点有关,但是接下来就没有思路了

这里有个很好的转换:

存在一条直线,将所有的线段投影到该直线上后,至少重叠于一个点<==>过重合点的直线,做该点的垂线,必然会与所有的直线相交。

所以枚举所有的端点,两两构成直线,来判断是否与所有线段相交即可。

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-8;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}
struct Point {double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const{return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const { //小在前return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}Point operator*(const double& k) const {return Point(k * x, k * y);}Point operator/(const double& k) const {return Point(x / k, y / k);}double operator^(const Point& b) const { //叉积return x * b.y - y * b.x;}double operator*(const Point& b) const {return x * b.x + y * b.y;}double len() {  //长度return sqrt(x * x + y * y);
//        return hypot(x, y);}double len2() {  //长度的平方return x * x + y * y;}double dis(Point p) { //两点距离return hypot(x - p.x, y - p.y);  //hypot是计算斜边长用的
//        return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));}double dis2(Point p) { //两点距离的平方return pow(x - p.x, 2.0) + pow(y - p.y, 2.0);}double rad(Point a, Point b) { //atan2(y, x),表示(x,y)在的角度(-pi,pi];Point p = *this;return fabs(atan2(fabs((a - p) ^ (b - p)), (a - p) * (b - p)));//角P的夹角}Point trunc(double r) { //转换为长度为r的向量,零向量除外double l = len();if (!dcmp(l)) return *this;r /= l;return Point(x * r, y * r);}Point rotleft() { //逆时针旋转90度return Point(-y, x);}Point rotright() { //顺时针旋转90度return Point(y, -x);}Point Rotate(Point p, double angle) {Point v = (*this) - p;double c = cos(angle), s = sin(angle);return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);}
};
struct Line {Point s, e;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}bool operator==(const Line& v) const {return (s == v.s) && (e == v.e);}Line(Point p, double angle) { //需要保证angle在[0, pi)s = p;if (dcmp(angle - pi / 2.0) == 0) {e = (s + Point(0, 1));}else {e = (s + Point(1, tan(angle)));}}Line(double a, double b, double c) { //ax + by + c = 0 一般式if (dcmp(a) == 0) {s = Point(0, -c / b);e = Point(1, -c / b);}else if (dcmp(b == 0)) {s = Point(-c / a, 0);e = Point(-c / a, 1);}else {s = Point(0, -c / b);e = Point(1, (-c - a) / b);}}void input() {s.input(); e.input();}void adjust() {if (e < s) swap(s, e);}double length() {return s.dis(e);}double angle() { //斜率,保证在[0, pi)double k = atan2(e.y - s.y, e.x - s.x);if (dcmp(k) < 0) k += pi;if (dcmp(k - pi) == 0) k -= pi;return k;}int relation(Point p) {int c = dcmp((p - s) ^ (e - s));if (c < 0) return 1; //在直线左侧else if (c > 0) return 2; //在直线右侧else return 3; //在直线上}bool pointonseg(Point p) { //点在线段上的判断(<=0表示包括端点)return dcmp((p - s) ^ (e - s)) == 0 && dcmp((p - s) * (p - e)) <= 0;}bool parallel(Line v) { //判断两向量平行return dcmp((e - s) ^ (v.e - v.s)) == 0;}double disPointToLine(Point p) { //点到直线的距离return fabs((p - s) ^ (e - s) / length());}double disPointToSeg(Point p) {  //点到线段的距离if (dcmp((p - s) * (e - s)) < 0 || dcmp((p - e) * (s - e)) < 0)return min(p.dis(s), p.dis(e));return disPointToLine(p);}Point lineprog(Point p) {  //点在直线上的投影点return s + ( ((e - s) * ((e - s) * (p - s))) / ((e - s).len2()) );}Point symmetrypoint(Point p) {  //点关于直线的对称点Point q = lineprog(p);return Point(2 * q.x - p.x, 2 * q.y - p.y);}int segcrossseg(Line v) { //两线段相交,2为规范相交,1为非规范相交int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));int d3 = dcmp((v.e - v.s) ^ (s - v.s));int d4 = dcmp((v.e - v.s) ^ (e - v.s));if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;return (d1 == 0 && dcmp((v.s - s) * (v.s - e)) <= 0) ||(d2 == 0 && dcmp((v.e - s) * (v.e - e)) <= 0) ||(d3 == 0 && dcmp((s - v.s) * (s - v.e)) <= 0) ||(d4 == 0 && dcmp((e - v.s) * (e - v.e)) <= 0);}int linecrossseg(Line v) {//直线与线段,2为规范相交,1为非规范相交int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));if ((d1 ^ d2) == -2) return 2;return (d1 == 0 || d2 == 0);}Point crossPoint(Line v) { //两直线的交点(保证不重合或平行)double a1 = (v.e - v.s) ^ (s - v.s);double a2 = (v.e - v.s) ^ (e - v.s);return Point((s.x * a2 - e.x * a1) / (a2 - a1), (s.y * a2 - e.y * a1) / (a2 - a1));}double disSegToSeg(Line v) { //线段到线段的距离,相交就是0return min(min(disPointToSeg(v.s), disPointToSeg(v.e)),min(v.disPointToSeg(s), v.disPointToSeg(e)));}
};int main() {int t;scanf("%d", &t);while(t--) {int n;scanf("%d", &n);vector<Line> li(n + 1);vector<Point> p(n * 2 + 1);for (int i = 0; i < n; i++) {li[i].s.input();li[i].e.input();p[i * 2 + 0] = li[i].s;p[i * 2 + 1] = li[i].e;}int np = 2 * n;bool f = false;for (int i = 0; i < np && !f; i++) {for (int j = i + 1; j < np && !f; j++) {if (p[i] == p[j]) continue;Line tmp = Line(p[i], p[j]);int cnt = 0;for (int k = 0; k < n; k++) {int isok = tmp.linecrossseg(li[k]);if (isok > 0) {cnt++;}}if (cnt == n) f = true;}}if (f) printf("Yes!\n");else printf("No!\n");}return 0;
}

POJ 1269 Intersecting Lines

题意: 判断平行,还是重合,还是相交

思路: 是否相交用叉积判断,是否重合用点到直线的距离判断

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-8;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}
struct Point {double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const{return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const { //小在前return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}Point operator*(const double& k) const {return Point(k * x, k * y);}Point operator/(const double& k) const {return Point(x / k, y / k);}double operator^(const Point& b) const { //叉积return x * b.y - y * b.x;}double operator*(const Point& b) const {return x * b.x + y * b.y;}double len() {  //长度return sqrt(x * x + y * y);
//        return hypot(x, y);}double len2() {  //长度的平方return x * x + y * y;}double dis(Point p) { //两点距离return hypot(x - p.x, y - p.y);  //hypot是计算斜边长用的
//        return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));}double dis2(Point p) { //两点距离的平方return pow(x - p.x, 2.0) + pow(y - p.y, 2.0);}double rad(Point a, Point b) { //atan2(y, x),表示(x,y)在的角度(-pi,pi];Point p = *this;return fabs(atan2(fabs((a - p) ^ (b - p)), (a - p) * (b - p)));//角P的夹角}Point trunc(double r) { //转换为长度为r的向量,零向量除外double l = len();if (!dcmp(l)) return *this;r /= l;return Point(x * r, y * r);}Point rotleft() { //逆时针旋转90度return Point(-y, x);}Point rotright() { //顺时针旋转90度return Point(y, -x);}Point Rotate(Point p, double angle) {Point v = (*this) - p;double c = cos(angle), s = sin(angle);return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);}
};
struct Line {Point s, e;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}bool operator==(const Line& v) const {return (s == v.s) && (e == v.e);}Line(Point p, double angle) { //需要保证angle在[0, pi)s = p;if (dcmp(angle - pi / 2.0) == 0) {e = (s + Point(0, 1));}else {e = (s + Point(1, tan(angle)));}}Line(double a, double b, double c) { //ax + by + c = 0 一般式if (dcmp(a) == 0) {s = Point(0, -c / b);e = Point(1, -c / b);}else if (dcmp(b == 0)) {s = Point(-c / a, 0);e = Point(-c / a, 1);}else {s = Point(0, -c / b);e = Point(1, (-c - a) / b);}}void input() {s.input(); e.input();}void adjust() {if (e < s) swap(s, e);}double length() {return s.dis(e);}double angle() { //斜率,保证在[0, pi)double k = atan2(e.y - s.y, e.x - s.x);if (dcmp(k) < 0) k += pi;if (dcmp(k - pi) == 0) k -= pi;return k;}int relation(Point p) {int c = dcmp((p - s) ^ (e - s));if (c < 0) return 1; //在直线左侧else if (c > 0) return 2; //在直线右侧else return 3; //在直线上}bool pointonseg(Point p) { //点在线段上的判断(<=0表示包括端点)return dcmp((p - s) ^ (e - s)) == 0 && dcmp((p - s) * (p - e)) <= 0;}bool parallel(Line v) { //判断两向量平行return dcmp((e - s) ^ (v.e - v.s)) == 0;}double disPointToLine(Point p) { //点到直线的距离return fabs((p - s) ^ (e - s) / length());}double disPointToSeg(Point p) {  //点到线段的距离if (dcmp((p - s) * (e - s)) < 0 || dcmp((p - e) * (s - e)) < 0)return min(p.dis(s), p.dis(e));return disPointToLine(p);}Point lineprog(Point p) {  //点在直线上的投影点return s + ( ((e - s) * ((e - s) * (p - s))) / ((e - s).len2()) );}Point symmetrypoint(Point p) {  //点关于直线的对称点Point q = lineprog(p);return Point(2 * q.x - p.x, 2 * q.y - p.y);}int segcrossseg(Line v) { //两线段相交,2为规范相交,1为非规范相交int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));int d3 = dcmp((v.e - v.s) ^ (s - v.s));int d4 = dcmp((v.e - v.s) ^ (e - v.s));if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;return (d1 == 0 && dcmp((v.s - s) * (v.s - e)) <= 0) ||(d2 == 0 && dcmp((v.e - s) * (v.e - e)) <= 0) ||(d3 == 0 && dcmp((s - v.s) * (s - v.e)) <= 0) ||(d4 == 0 && dcmp((e - v.s) * (e - v.e)) <= 0);}int linecrossseg(Line v) {//直线与线段,2为规范相交,1为非规范相交int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));if ((d1 ^ d2) == -2) return 2;return (d1 == 0 || d2 == 0);}Point crossPoint(Line v) { //两直线的交点(保证不重合或平行)double a1 = (v.e - v.s) ^ (s - v.s);double a2 = (v.e - v.s) ^ (e - v.s);return Point((s.x * a2 - e.x * a1) / (a2 - a1), (s.y * a2 - e.y * a1) / (a2 - a1));}double disSegToSeg(Line v) { //线段到线段的距离,相交就是0return min(min(disPointToSeg(v.s), disPointToSeg(v.e)),min(v.disPointToSeg(s), v.disPointToSeg(e)));}
};int main() {int n;scanf("%d", &n);printf("INTERSECTING LINES OUTPUT\n");for (int i = 1; i <= n; i++) {Point a, b, c, d;a.input();b.input();c.input();d.input();Line ab = Line(a, b);Line cd = Line(c, d);if (ab.parallel(cd)) {int d = ab.disPointToLine(c);if (d > 0) {printf("NONE\n");}else {printf("LINE\n");}}else {Point res = ab.crossPoint(cd);printf("POINT %.2f %.2f\n", res.x, res.y);}}printf("END OF OUTPUT\n");return 0;
}

POJ 1556 The Doors(判断线段相交+最短路径)

题意: 给定一个 $10 \times 10 $ 大小的矩形,起点为 ( 0 , 5 ) (0, 5) (0,5), 终点为 ( 10 , 5 ) (10, 5) (10,5) 中间竖直方向最多有 18 18 18 堵墙壁,每堵墙壁都有两个门。求起点到终点的最短路径。

思路: 一开始是打算 按照端点直接 d f s dfs dfs 爆搜,但是每堵墙不一定一定是经过端点才是最优的,因此直接 p a s s pass pass 。然后打算从当前点往能到达的最远点走,但是不行

写了半天,结果是个图论:

首先,枚举所有端点(包括起点和终点)连成的线段,若这条线段没有经过任何墙壁,就将这两个点建边,边权值为两点之间的距离,建完图后跑一边 d i j dij dij 求单源最短路就可以了。

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-8;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}
struct Point {double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const{return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const { //小在前return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}Point operator*(const double& k) const {return Point(k * x, k * y);}Point operator/(const double& k) const {return Point(x / k, y / k);}double operator^(const Point& b) const { //叉积return x * b.y - y * b.x;}double operator*(const Point& b) const {return x * b.x + y * b.y;}double len() {  //长度return sqrt(x * x + y * y);
//        return hypot(x, y);}double len2() {  //长度的平方return x * x + y * y;}double dis(Point p) { //两点距离return hypot(x - p.x, y - p.y);  //hypot是计算斜边长用的
//        return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));}double dis2(Point p) { //两点距离的平方return pow(x - p.x, 2.0) + pow(y - p.y, 2.0);}double rad(Point a, Point b) { //atan2(y, x),表示(x,y)在的角度(-pi,pi];Point p = *this;return fabs(atan2(fabs((a - p) ^ (b - p)), (a - p) * (b - p)));//角P的夹角}Point trunc(double r) { //转换为长度为r的向量,零向量除外double l = len();if (!dcmp(l)) return *this;r /= l;return Point(x * r, y * r);}Point rotleft() { //逆时针旋转90度return Point(-y, x);}Point rotright() { //顺时针旋转90度return Point(y, -x);}Point Rotate(Point p, double angle) {Point v = (*this) - p;double c = cos(angle), s = sin(angle);return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);}
};
struct Line {Point s, e;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}bool operator==(const Line& v) const {return (s == v.s) && (e == v.e);}void input() {s.input(); e.input();}int relation(Point p) {int c = dcmp((p - s) ^ (e - s));if (c < 0) return 1; //在直线左侧else if (c > 0) return 2; //在直线右侧else return 3; //在直线上}bool pointonseg(Point p) { //点在线段上的判断(<=0表示包括端点)return dcmp((p - s) ^ (e - s)) == 0 && dcmp((p - s) * (p - e)) <= 0;}bool parallel(Line v) { //判断两向量平行return dcmp((e - s) ^ (v.e - v.s)) == 0;}double disPointToLine(Point p) { //点到直线的距离return fabs((p - s) ^ (e - s) / length());}double disPointToSeg(Point p) {  //点到线段的距离if (dcmp((p - s) * (e - s)) < 0 || dcmp((p - e) * (s - e)) < 0)return min(p.dis(s), p.dis(e));return disPointToLine(p);}Point lineprog(Point p) {  //点在直线上的投影点return s + ( ((e - s) * ((e - s) * (p - s))) / ((e - s).len2()) );}Point symmetrypoint(Point p) {  //点关于直线的对称点Point q = lineprog(p);return Point(2 * q.x - p.x, 2 * q.y - p.y);}int segcrossseg(Line v) { //两线段相交,2为规范相交,1为非规范相交int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));int d3 = dcmp((v.e - v.s) ^ (s - v.s));int d4 = dcmp((v.e - v.s) ^ (e - v.s));if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;return (d1 == 0 && dcmp((v.s - s) * (v.s - e)) <= 0) ||(d2 == 0 && dcmp((v.e - s) * (v.e - e)) <= 0) ||(d3 == 0 && dcmp((s - v.s) * (s - v.e)) <= 0) ||(d4 == 0 && dcmp((e - v.s) * (e - v.e)) <= 0);}
};
vector<Line> g[100];
vector<Point> p;
double ans;
int n;
int st, ed;
typedef pair<double, int> P;
struct DIJ{struct edge{int u, v;double cost;int next;}es[10010];int head[100];double d[100];int V, tot;void init(int _n) {V = _n; tot = 0;for (int i = 0; i <= _n; i++) {head[i] = -1;}}void add_edge(int u, int v, double cost) {es[tot].u = u;es[tot].v = v;es[tot].cost = cost;es[tot].next = head[u];head[u] = tot++;}void dijstra(int s) {priority_queue<P, vector<P>, greater<P> > pq;for (int i = 0; i <= V; i++) d[i] = 1e9;d[s] = 0;pq.push(P(0, s));while (pq.size()) {P p = pq.top(); pq.pop();int v = p.second;if (d[v] < p.first) continue;for (int i = head[v]; i != -1; i = es[i].next) {int from = es[i].u;int to = es[i].v;double cost = es[i].cost;if (d[to] > d[from] + cost) {d[to] = d[from] + cost;pq.push(P(d[to], to));}}}}
}G;int main() {while (scanf("%d", &n)) {if (n == -1) break;if (n == 0) {printf("10.00\n");continue;}p.clear();for (int i = 0; i < n; i++) {g[i].clear();}p.push_back(Point(0, 5));for (int i = 0; i < n; i++) {double x;scanf("%lf", &x);vector<double> y;y.push_back(0);for (int j = 0; j < 4; j++) {double yy;scanf("%lf", &yy);p.push_back(Point(x, yy));y.push_back(yy);}y.push_back(10.0);for (int j = 0; j < (int)y.size(); j += 2) {g[i].push_back(Line(Point(x, y[j]), Point(x, y[j + 1])));}}p.push_back(Point(10, 5));st = 0;ed = p.size() - 1;
//        for (int i = 0; i < n; i++) {//            printf("%d: \n", i);
//            for (int j = 0; j < (int)g[i].size(); j++) {//                g[i][j].s.output();
//                g[i][j].e.output();
//            }
//        }G.init(ed);for (int i = 0; i <= ed; i++) {for (int j = i + 1; j <= ed; j++) {Line tmp = Line(p[i], p[j]);bool f = true;for (int k = 0; k < n && f; k++) {for (int c = 0; c < (int)g[k].size() && f; c++) {int isok = tmp.segcrossseg(g[k][c]);if (isok == 2) f = false;}}if (f) {G.add_edge(i, j, p[i].dis(p[j]));G.add_edge(j, i, p[i].dis(p[j]));}}}G.dijstra(0);printf("%.2f\n", G.d[ed]);}return 0;
}

POJ 1066 Treasure Hunt

题意: 一个 100 × 100 100 \times 100 100×100 的矩形中,有 n n n 面交错的墙。其中有一个宝藏点,求从矩形外走到宝藏处需要凿开的最少墙数。(只能在墙的中间凿洞)

思路:

开始理解的墙中间是题目给的那 n n n 块墙,然后先建图在求最短路做,但是一直 w a wa wa。 后来看了题解,才知道,这个中间是两块区域间的墙,不是整块 … \dots … 这样只需要枚举起点,然后与宝藏点连成线段,再找到所有相交的墙壁面数,其中最小的就是答案。

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-8;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}
struct Point {double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const{return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const { //小在前return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}Point operator*(const double& k) const {return Point(k * x, k * y);}Point operator/(const double& k) const {return Point(x / k, y / k);}double operator^(const Point& b) const { //叉积return x * b.y - y * b.x;}double operator*(const Point& b) const {return x * b.x + y * b.y;}double len() {  //长度return sqrt(x * x + y * y);
//        return hypot(x, y);}double len2() {  //长度的平方return x * x + y * y;}double dis(Point p) { //两点距离return hypot(x - p.x, y - p.y);  //hypot是计算斜边长用的
//        return sqrt((x - p.x) * (x - p.x) + (y - p.y) * (y - p.y));}double dis2(Point p) { //两点距离的平方return pow(x - p.x, 2.0) + pow(y - p.y, 2.0);}
};
struct Line {Point s, e;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}bool operator==(const Line& v) const {return (s == v.s) && (e == v.e);}void input() {s.input(); e.input();}int segcrossseg(Line v) { //两线段相交,2为规范相交,1为非规范相交int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));int d3 = dcmp((v.e - v.s) ^ (s - v.s));int d4 = dcmp((v.e - v.s) ^ (e - v.s));if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;return (d1 == 0 && dcmp((v.s - s) * (v.s - e)) <= 0) ||(d2 == 0 && dcmp((v.e - s) * (v.e - e)) <= 0) ||(d3 == 0 && dcmp((s - v.s) * (s - v.e)) <= 0) ||(d4 == 0 && dcmp((e - v.s) * (e - v.e)) <= 0);}int linecrossseg(Line v) {//直线与线段,2为规范相交,1为非规范相交int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));if ((d1 ^ d2) == -2) return 2;return (d1 == 0 || d2 == 0);}
};
int n;
vector<int> x1(105, 0), x2(105, 0), yy(105, 0), y2(105, 0);
vector<Line> li;
vector<Point> in, out;
vector<Point> all;
Point treasure;
int main() {scanf("%d", &n);for (int i = 0; i < n; i++) {Point a, b;a.input(); b.input();if (dcmp(a.x - 100) == 0) y2[a.y]++;else if (dcmp(a.x - 0) == 0) yy[a.y]++;else if (dcmp(a.y - 100) == 0) x2[a.x]++;else if (dcmp(a.y - 0) == 0) x1[a.x]++;if (dcmp(b.x - 100) == 0) y2[b.y]++;else if (dcmp(b.x - 0) == 0) yy[b.y]++;else if (dcmp(b.y - 100) == 0) x2[b.x]++;else if (dcmp(b.y - 0) == 0) x1[b.x]++;li.push_back(Line(a, b));in.push_back((a + b) / 2);}li.push_back(Line(Point(0, 0), Point(0, 100)));li.push_back(Line(Point(0, 100), Point(100, 100)));li.push_back(Line(Point(100, 100), Point(100, 0)));li.push_back(Line(Point(0, 0), Point(100, 0)));treasure.input();all.push_back(treasure);int cnt1 = in.size();for (int i = 0; i < cnt1; i++)all.push_back(in[i]);x1[0]++; x1[100]++;x2[0]++; x2[100]++;yy[0]++; yy[100]++;y2[0]++; y2[100]++;int last = 0;for (int i = 1; i <= 100; i++) {if (x1[i] > 0) {double pos = (last + i) / 2.0;out.push_back(Point(pos, 0));last = i;}}last = 0;for (int i = 1; i <= 100; i++) {if (x2[i] > 0) {double pos = (last + i) / 2.0;out.push_back(Point(pos, 100.0));last = i;}}last = 0;for (int i = 1; i <= 100; i++) {if (yy[i] > 0) {double pos = (last + i) / 2.0;out.push_back(Point(0, pos));last = i;}}last = 0;for (int i = 1; i <= 100; i++) {if (y2[i] > 0) {double pos = (last + i) / 2.0;out.push_back(Point(100.0, pos));last = i;}}int cnt2 = out.size();for (int i = 0; i < (int)out.size(); i++) {all.push_back(out[i]);}int ans = INF;for (int i = 0; i < cnt2; i++) {Line tmp = Line(treasure, out[i]);int cnt = 0;for(int j = 0; j < (int)li.size(); j++) {int k = tmp.segcrossseg(li[j]);if (k > 0) cnt++;}ans = min(ans, cnt);}printf("Number of doors = %d\n", ans);return 0;
}

POJ 1696 Space Ant(极角排序)

题意: 给定 n n n 个点,要求你找出一条路径经过最多的点,路径不能交叉,路径始终只能是当前前进方向的左边。

思路: 不难发现,无论怎么给定点,都能够走完所有的点,因为可以画出一个凸包,凸包内的点始终在凸包前进方向的左侧,这样逆时针一圈一圈地走就能得到答案。

用 极角排序 ,这里用叉积来作极角排序,具体实现看代码

每次选定上一个点作为基准对剩下的点进行极角排序,然后剩下的点中的第一个点就是下一个路径点。一直排序直到走完所有点。

注意题目要求从 y y y 坐标最小的点出发。。。。。。

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-8;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}
struct Point{double x, y;int id;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const{return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const {return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const{return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const{return Point(x + b.x, y + b.y);}Point operator*(const double& k) const{return Point(x * k, y * k);}double operator*(const Point& b) const {return x * b.x + y * b.y;}Point operator/(const double& k) const{return Point(x / k, y / k);}double operator^(const Point& b) const{return x * b.y - y * b.x;}double dis(Point p) {return hypot(x - p.x, y - p.y);
//        return sqrt((*this - p) * (*this - p));}
};
Point p[105];
int s;
bool cmp(Point a, Point b) { //极角排序double tmp = (a - p[s]) ^ (b - p[s]);if (dcmp(tmp) == 0)return a.dis(p[s]) < b.dis(p[s]);else if (dcmp(tmp) < 0) //点b偏下return false;elsereturn true;
}
int main() {int t;scanf("%d", &t);while (t--) {int n;scanf("%d", &n);vector<Point> last;for (int i = 0, id; i < n; i++) {scanf("%d", &id);p[i + 1].input(), p[i + 1].id = id;last.push_back(p[i + 1]);if (i > 0 && (last[i].y < last[0].y || (last[i].y == last[0].y && last[i].x < last[0].x)))swap(last[0], last[i]);}
//        sort(last.begin(), last.end());vector<int> ans;do {if ((int)last.size() == 0) break;ans.push_back(last[0].id);s = last[0].id;last.erase(last.begin());sort(last.begin(), last.end(), cmp);} while (true);printf("%d", ans.size());for (int i = 0; i < (int)ans.size(); i++)printf(" %d", ans[i]);printf("\n");}return 0;
}

POJ 3347 Kadj Squares(扩大数据避免小数)

题意: 有若干个边长为整数的正方形,要将他们倾斜 45 45 45度 放在第一象限中,底要接触 x x x 轴,并且尽可能的紧凑,求从上方观察,能看到哪些正方形。

思路: 先将每个正方形的边长放大 2 \sqrt2 2 ​ 倍,再投影下来就是整数了,避免的浮点数的精度问题。 然后将所有正方形的区间范围表示出来,再对重合的部分根据两个正方形的边长大小比较进行修改。

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;struct node{int l, r, len;node() {}node(int _l, int _r, int _len) {l = _l; r = _r;len = _len;}
};
int main() {int n;while (scanf("%d", &n) && n) {vector<node> a(n + 1);for (int i = 1; i <= n; i++) {a[i].l = a[i].r = 0;scanf("%d", &a[i].len);}for (int i = 1; i <= n; i++) {for (int j = 1; j < i; j++) { //找到左端点a[i].l = max(a[i].l, a[j].r - abs(a[i].len - a[j].len));}a[i].r = a[i].l + 2 * a[i].len; //确定所在区间}for (int i = 1; i <= n; i++) {for (int j = 1; j < i; j++) {if (a[j].r > a[i].l) { //前面正方形的右边界比后面正方形的左边界要大if (a[j].len > a[i].len) { //前面的正方形更大a[i].l = a[j].r;}else if (a[j].len < a[i].len) {a[j].r = a[i].l;}}}}int c = 0;for (int i = 1; i <= n; i++) {if (a[i].l < a[i].r) {if (c++ > 0) printf(" ");printf("%d", i);}}printf("\n");}return 0;
}

POJ 2826 An Easy Problem?!(大力出奇迹?)

题意: 就给两块木板,看能接到多少面积的雨水,要注意这里的雨是垂直下的

思路: 大力出奇迹,最吐血的是答案加一个 e p s eps eps 才能过。。

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<algorithm>
#define fi first
#define se second
#include<stdlib.h>
#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-6;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}struct Point{double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const {return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}
//    bool operator<(const Point& b) const {//        return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;
//    }Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}double operator*(const Point& b) const {return x * b.x + y * b.y;}double operator^(const Point& b) const {return x * b.y - y * b.x;}double dis(Point b) {return sqrt((*this - b) * (*this - b));}
};struct Line{Point s, e;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}bool operator==(const Line& v) const {return (s == v.s) && (e == v.e);}void adjust() { //保证从下往上if (s.y > e.y) swap(s, e);}bool parallel(Line v) {return dcmp((e - s) ^ (v.e -v.s)) == 0;}int segcrossseg(Line v) {int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));int d3 = dcmp((v.e - v.s) ^ (s - v.s));int d4 = dcmp((v.e - v.s) ^ (e - v.s));if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;return (d1 == 0 && dcmp((v.s - s) * (v.s - e)) <= 0) ||(d2 == 0 && dcmp((v.e - s) * (v.e - e)) <= 0) ||(d3 == 0 && dcmp((s - v.s) * (s - v.e)) <= 0) ||(d4 == 0 && dcmp((e - v.s) * (e - v.e)) <= 0);}int linecrossseg(Line v) {int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));if ((d1 ^ d2) == -2) return 2;return (d1 == 0 || d2 == 0);}Point crossPoint(Line v) {double a1 = (v.e - v.s) ^ (s - v.s);double a2 = (v.e - v.s) ^ (e - v.s);return Point((s.x * a2 - e.x * a1) / (a2 - a1), (s.y * a2 - e.y * a1) / (a2 - a1));}
};
int main() {int t;scanf("%d", &t);while (t--) {Point a, b, c, d;a.input(); b.input();c.input(); d.input();Line l1 = Line(a, b); l1.adjust();Line l2 = Line(c, d); l2.adjust();Line lx = Line(Point(0, 0), Point(1, 0));Line ly = Line(Point(0, 0), Point(0, 1));if (l1.parallel(lx) || l2.parallel(lx)) { //存在水平printf("0.00\n");continue;}
//        printf("2\n");if (l1.parallel(l2)) { //平行线printf("0.00\n");continue;}
//        printf("3\n");int tmp = l1.segcrossseg(l2); //判断相交情况if (tmp == 0) {  //不相交printf("0.00\n");continue;}
//        printf("4\n");Point p = l1.crossPoint(l2);Line lp = Line(p, Point(p.x, p.y + 1));int k = lp.linecrossseg(Line(l1.e, l2.e)); //判断是否在两边if (p == l1.e || p == l2.e) { //交点为某一条线段的偏上的点printf("0.00\n");continue;}
//        printf("5\n");if (k == 0) { //同一边if (((l1.e - p) ^ (l2.e - p)) > 0 && dcmp(l2.e.x - l1.e.x) >= 0) { //l2刚好遮住l1printf("0.00\n");continue;}if (((l1.e - p) ^ (l2.e - p)) < 0 && dcmp(l1.e.x - l2.e.x) >= 0) { //l1刚好遮住l2printf("0.00\n");continue;}}
//        printf("6\n");double ans = 0;Line lpp1 = Line(l1.e, Point(l1.e.x + 1, l1.e.y));Line lpp2 = Line(l2.e, Point(l2.e.x + 1, l2.e.y));int s1 = lpp1.linecrossseg(l2);int s2 = lpp2.linecrossseg(l1);if (s1 > 0) {Point o = l2.crossPoint(lpp1);ans = ((o - p) ^ (l1.e - p)) / 2.0;ans = fabs(ans);}else {Point o = l1.crossPoint(lpp2);ans = ((o - p) ^ (l2.e - p)) / 2.0;ans = fabs(ans);}printf("%.2f\n", ans + eps);}return 0;
}/*
6259 2664 8292 9080
1224 2972 9097 9680
5928.89
*/

POJ 3449 Geometric Shapes(非常恶心的读入)

题意: 给定 n n n 若干个平面封闭图形,判断相交的情况,边碰到也算相交。

有个知识点,已知正方形对角线的两顶点,求另外两个顶点

将对角线左旋 45 45 45度 和右旋 45 45 45 度 ,再分别求投影点即可

思路: emmm,写的时候仔细一点,写好读入就基本OK了。

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<string>
#include<algorithm>
#define fi first
#define se second
//#include<stdlib.h>
//#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const double eps = 1e-7;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}struct Point{double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const {return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const {return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}double operator*(const Point& b) const {return x * b.x + y * b.y;}double operator^(const Point& b) const {return x * b.y - y * b.x;}Point operator/(const double& k) const {return Point(x / k, y / k);}Point operator*(const double& k) const {return Point(x * k, y * k);}double dis(Point p) {return sqrt((*this - p) * (*this - p));}double len() {return sqrt(x * x + y * y);}double len2() {return x * x + y * y;}Point Ratate(Point p, double angle) {Point v = (*this) - p;double c = cos(angle), s = sin(angle);return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);}
};struct Line{Point s, e;int id;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}void output() {printf("%d:\n", id);s.output(); e.output();}void adjust() {if (s.y > e.y) swap(s, e);}double length() {return s.dis(e);}bool parallel(Line v) {return dcmp((e - s) ^ (v.e - v.s)) == 0;}Point lineprog(Point p) {return s + ( ((e - s) * ((e - s) * (p - s))) / ((e - s).len2()));}double disPointToLine(Point p) {return fabs((p - s) ^ (e - s) / length());}double disPointToSeg(Point p) {if (dcmp((p - s) * (e - s)) < 0 || dcmp((p - e) * (s - e)) < 0)return min(p.dis(s), p.dis(e));return disPointToLine(p);}int segcrossseg(Line v) {int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));int d3 = dcmp((v.e - v.s) ^ (s - v.s));int d4 = dcmp((v.e - v.s) ^ (e - v.s));if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;return (d1 == 0 && dcmp((v.s - s) * (v.s - e)) <= 0) ||(d2 == 0 && dcmp((v.e - s) * (v.e - e)) <= 0) ||(d3 == 0 && dcmp((s - v.s) * (s - v.e)) <= 0) ||(d4 == 0 && dcmp((e - v.s) * (e - v.e)) <= 0);}Point crossPoint(Line v) {double a1 = (v.e - v.s) ^ (s - v.s);double a2 = (v.e - v.s) ^ (e - v.s);return Point((s.x * a2 - e.x * a1) / (a2 - a1), (s.y * a2 - e.y * a1) / (a2 - a1));}double dissegtoseg(Line v) {return min(min(disPointToSeg(v.s), disPointToSeg(v.e)),min(v.disPointToSeg(s), v.disPointToSeg(e)));}
};vector<vector<int>> g(30, vector<int>(30));
vector<Line> li;
vector<int> cl(30, 0);
vector<int> vis(30, 0);void add_edge(int u, int v) {if (!g[u][v]) {cl[u]++;cl[v]++;}g[u][v] = g[v][u] = 1;
}void getsquare(Point a, Point b, Point& b1, Point& b2) {Point c = b.Ratate(a, -pi / 4.0);Point d = b.Ratate(a, pi / 4.0);Line ac = Line(a, c);Line ad = Line(a, d);b1 = ac.lineprog(b);b2 = ad.lineprog(b);
}void getRectangle(Point a, Point b, Point c, Point& d) {//保证第二个点为直角点Point o = (a + c) / 2;d = Point(2 * o.x - b.x, 2 * o.y - b.y);
}Point change(string str) {int num[2] = {0};int c = 0;int f = 1;for (int i = 0; i < str.size(); i++) {if (str[i] >= '0' && str[i] <= '9') {num[c] = num[c] * 10 + str[i] - '0';}else if (str[i] == ',') {num[c] *= f;f = 1;c++;}else if (str[i] == '-') f = -1;else if (str[i] == ')') {num[c] *= f;}}return Point(num[0], num[1]);
}void show(vector<Point> p) {for (int i = 0; i < (int)p.size(); i++)p[i].output();
}void solve() {for (int i = 0; i < 26; i++) {if (vis[i]) {if (cl[i] == 0) {printf("%c has no intersections\n", 'A' + i);}else if (cl[i] == 1) {printf("%c intersects with ", 'A' + i);for (int j = 0; j < 26; j++) {if (g[i][j])printf("%c\n", 'A' + j);}}else if (cl[i] == 2) {printf("%c intersects with ", 'A' + i);int f = 0;for (int j = 0; j < 26; j++) {if (g[i][j]) {if (f > 0) printf(" and ");printf("%c", 'A' + j);if (f > 0) printf("\n");f++;}}}else {printf("%c intersects with ", 'A' + i);int f = 1;for (int j = 0; j < 26; j++) {if (g[i][j]) {if (f == cl[i]) {printf("and %c\n", 'A' + j);}else {printf("%c, ", 'A' + j);}f++;}}}}}
}int main() {string s;while (cin >> s) {if (s == ".") break;else if (s == "-") {//            for (int i = 0; i < (int)li.size(); i++) {//                li[i].output();
//            }for (int i = 0; i < (int)li.size(); i++) {for (int j = i + 1; j < (int)li.size(); j++) {if (li[i].id == li[j].id) continue;int s = li[i].segcrossseg(li[j]);if (s > 0) add_edge(li[i].id, li[j].id);}}solve();printf("\n");for (int i = 0; i < 30; i++) vis[i] = 0;for (int i = 0; i < 30; i++) {vis[i] = 0;cl[i] = 0;for (int j = 0; j < 30; j++) {g[i][j] = 0;}}li.clear();}else {int id = s[0] - 'A';vis[id] = 1;string kind;cin >> kind;string pt;if (kind == "square") {vector<Point> p(4);cin >> pt; p[0] = change(pt);cin >> pt; p[2] = change(pt);getsquare(p[0], p[2], p[1], p[3]);
//                show(p);for (int i = 0; i < 4; i++) {Line line = Line(p[i], p[(i + 1) % 4]);line.id = id;li.push_back(line);}}else if (kind == "rectangle") {vector<Point> p(4);for (int i = 0; i < 3; i++) {cin >> pt;p[i] = change(pt);}getRectangle(p[0], p[1], p[2], p[3]);
//                show(p);for (int i = 0; i < 4; i++) {Line line = Line(p[i], p[(i + 1) % 4]);line.id = id;li.push_back(line);}}else if (kind == "line") {vector<Point> p(2);for (int i = 0; i < 2; i++) {cin >> pt;p[i] = change(pt);}
//                show(p);Line line = Line(p[0], p[1]);line.id = id;li.push_back(line);}else if (kind == "triangle") {vector<Point> p(3);for (int i = 0; i < 3; i++) {cin >> pt;p[i] = change(pt);}
//                show(p);for (int i = 0; i < 3; i++) {Line line = Line(p[i], p[(i + 1) % 3]);line.id = id;li.push_back(line);}}else if (kind == "polygon") {int cnt;cin >> cnt;vector<Point> p(cnt);for (int i = 0; i < cnt; i++) {cin >> pt;p[i] = change(pt);}
//                show(p);for (int i = 0; i < cnt; i++) {Line line = Line(p[i], p[(i + 1) % cnt]);line.id = id;li.push_back(line);}}}}return 0;
}

POJ 1584 A Round Peg in a Ground Hole(凸包+点线圆的相对关系)

题意: 给定一个多边形,判断是否为凸多边形,以及圆是否在该凸多边形内部

思路: 直接先对所给定的点求一个凸包,看凸包的节点数 (注意:这里的凸包要求不是严格的,可以存在点的角度为180),或者对每一对相邻的边进行叉积**(叉积注意方向要一致)** ,如果有正有负就说明不是凸包。 接下来先判断圆心是否在凸包内,可以用面积法求。最后,因为圆心已经在凸包内,只需要求一下圆心到各线段(可以当做直线来求,以为保证了圆心已经在凸包内了)的距离与半径的关系即可

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<string>
#include<algorithm>
#define fi first
#define se second
//#include<stdlib.h>
//#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const int N = 1e3 + 10;const double eps = 1e-7;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}struct Point{double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const {return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const {return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}double operator*(const Point& b) const {return x * b.x + y * b.y;}double operator^(const Point& b) const {return x * b.y - y * b.x;}Point operator/(const double& k) const {return Point(x / k, y / k);}Point operator*(const double& k) const {return Point(x * k, y * k);}double dis(Point p) {return sqrt((*this - p) * (*this - p));}double len() {return sqrt(x * x + y * y);}double len2() {return x * x + y * y;}Point Ratate(Point p, double angle) {Point v = (*this) - p;double c = cos(angle), s = sin(angle);return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);}
}p[N], ch[N];struct Line{Point s, e;int id;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}void output() {printf("%d:\n", id);s.output(); e.output();}void adjust() {if (s.y > e.y) swap(s, e);}double length() {return s.dis(e);}bool parallel(Line v) {return dcmp((e - s) ^ (v.e - v.s)) == 0;}Point lineprog(Point p) {return s + ( ((e - s) * ((e - s) * (p - s))) / ((e - s).len2()));}double disPointToLine(Point p) {return fabs((p - s) ^ (e - s) / length());}double disPointToSeg(Point p) {  //点到线段的距离if (dcmp((p - s) * (e - s)) < 0 || dcmp((p - e) * (s - e)) < 0)return min(p.dis(s), p.dis(e));return disPointToLine(p);}int segcrossseg(Line v) {int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));int d3 = dcmp((v.e - v.s) ^ (s - v.s));int d4 = dcmp((v.e - v.s) ^ (e - v.s));if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;return (d1 == 0 && dcmp((v.s - s) * (v.s - e)) <= 0) ||(d2 == 0 && dcmp((v.e - s) * (v.e - e)) <= 0) ||(d3 == 0 && dcmp((s - v.s) * (s - v.e)) <= 0) ||(d4 == 0 && dcmp((e - v.s) * (e - v.e)) <= 0);}Point crossPoint(Line v) {double a1 = (v.e - v.s) ^ (s - v.s);double a2 = (v.e - v.s) ^ (e - v.s);return Point((s.x * a2 - e.x * a1) / (a2 - a1), (s.y * a2 - e.y * a1) / (a2 - a1));}double dissegtoseg(Line v) {return min(min(disPointToSeg(v.s), disPointToSeg(v.e)),min(v.disPointToSeg(s), v.disPointToSeg(e)));}
};struct Circle{Point o;double r;Circle() {}Circle(Point _o, double _r) {o = _o;r = _r;}
};int andrew(Point p[], Point ch[], int n) {sort(p + 1, p + n + 1);int top = 0;for (int i = 1; i <= n; i++) {while ((top > 1) & (((ch[top] - ch[top - 1]) ^ (p[i] - ch[top])) < 0))--top;ch[++top] = p[i];}int tmp = top;for (int i = n - 1; i; --i) {while ((top > tmp) && (((ch[top] - ch[top - 1]) ^ (p[i] - ch[top])) < 0))--top;ch[++top] = p[i];}if (n > 1) top--;return top;
}bool is_in(Point ch[], int n, Point o) {double S = 0;for (int i = 2; i < n; i++) {double tmp = (ch[i - 1] - ch[0]) ^ (ch[i] - ch[0]);tmp = fabs(tmp);S += tmp;}double s = 0;for (int i = 1; i <= n; i++) {double tmp = (ch[i - 1] - o) ^ (ch[i] - o);tmp = fabs(tmp);s += tmp;}
//    printf("%.2f %.2f\n", S, s);return dcmp(S - s) == 0;
}bool is_ok(Point ch[], int n, Circle cir) {for (int i = 1; i <= n; i++) {Line li = Line(ch[i], ch[i - 1]);double dis = li.disPointToLine(cir.o);if (dcmp(cir.r - dis) > 0) return false;}return true;
}
int main() {int n;while (scanf("%d", &n)) {if (n < 3) break;Circle cir;scanf("%lf%lf%lf", &cir.r, &cir.o.x, &cir.o.y);for (int i = 1; i <= n; i++) {p[i].input();}int cnt = andrew(p, ch, n);ch[0] = ch[cnt];if (cnt < n) {printf("HOLE IS ILL-FORMED\n");continue;}
//        for (int i = 0; i < cnt; i++) {//            ch[i].output();
//        }if (is_in(ch, cnt, cir.o) && is_ok(ch, cnt, cir)) {printf("PEG WILL FIT\n");}else {printf("PEG WILL NOT FIT\n");}}return 0;
}/*
6 1 2 2
1 3
1 2
1 1
3 1
4 2
2 4
*/

POJ 2074 Line of Sight(平面视线问题)

题意: 给一条马路,一座房子,以及若干障碍物(所有的东西都是平行于 x x x 轴的)要求在马路上能看到整个房子的最长路段

思路: 先将在房子旁边和房子上面的障碍物都过滤掉,在剩下的障碍物中去掉末尾相同但起始点更小的障碍物,然后按末尾点为关键字进行升序排序,排序后对相邻的两个障碍物,进行计算,求在马路中能看到完整房子的路段长度。对开始和结束的端点在进行特判,最后取最大值就是答案。

代码:

#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<map>
#include<cstring>
#include<string>
#include<algorithm>
#define fi first
#define se second
//#include<stdlib.h>
//#include <time.h>
//srand((unsigned)time(NULL));
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
using namespace std;const int N = 1e3 + 10;const double eps = 1e-7;
const double pi = acos(-1.0);
int dcmp(double x) {if (fabs(x) < eps) return 0;return x > 0 ? 1 : -1;
}struct Point{double x, y;Point() {}Point(double _x, double _y) {x = _x; y = _y;}void input() {scanf("%lf%lf", &x, &y);}void output() {printf("%.2f %.2f\n", x, y);}bool operator==(const Point& b) const {return dcmp(x - b.x) == 0 && dcmp(y - b.y) == 0;}bool operator<(const Point& b) const {return dcmp(x - b.x) == 0 ? dcmp(y - b.y) < 0 : x < b.x;}Point operator-(const Point& b) const {return Point(x - b.x, y - b.y);}Point operator+(const Point& b) const {return Point(x + b.x, y + b.y);}double operator*(const Point& b) const {return x * b.x + y * b.y;}double operator^(const Point& b) const {return x * b.y - y * b.x;}Point operator/(const double& k) const {return Point(x / k, y / k);}Point operator*(const double& k) const {return Point(x * k, y * k);}double dis(Point p) {return sqrt((*this - p) * (*this - p));}double len() {return sqrt(x * x + y * y);}double len2() {return x * x + y * y;}Point Ratate(Point p, double angle) {Point v = (*this) - p;double c = cos(angle), s = sin(angle);return Point(p.x + v.x * c - v.y * s, p.y + v.x * s + v.y * c);}
};struct Line{Point s, e;int id;Line() {}Line(Point _s, Point _e) {s = _s; e = _e;}void output() {printf("%d:\n", id);s.output(); e.output();}void adjust() {if (s.y > e.y) swap(s, e);}double length() {return s.dis(e);}bool parallel(Line v) {return dcmp((e - s) ^ (v.e - v.s)) == 0;}Point lineprog(Point p) {return s + ( ((e - s) * ((e - s) * (p - s))) / ((e - s).len2()));}double disPointToLine(Point p) {return fabs((p - s) ^ (e - s) / length());}double disPointToSeg(Point p) {  //点到线段的距离if (dcmp((p - s) * (e - s)) < 0 || dcmp((p - e) * (s - e)) < 0)return min(p.dis(s), p.dis(e));return disPointToLine(p);}int segcrossseg(Line v) {int d1 = dcmp((e - s) ^ (v.s - s));int d2 = dcmp((e - s) ^ (v.e - s));int d3 = dcmp((v.e - v.s) ^ (s - v.s));int d4 = dcmp((v.e - v.s) ^ (e - v.s));if ((d1 ^ d2) == -2 && (d3 ^ d4) == -2) return 2;return (d1 == 0 && dcmp((v.s - s) * (v.s - e)) <= 0) ||(d2 == 0 && dcmp((v.e - s) * (v.e - e)) <= 0) ||(d3 == 0 && dcmp((s - v.s) * (s - v.e)) <= 0) ||(d4 == 0 && dcmp((e - v.s) * (e - v.e)) <= 0);}Point crossPoint(Line v) {double a1 = (v.e - v.s) ^ (s - v.s);double a2 = (v.e - v.s) ^ (e - v.s);return Point((s.x * a2 - e.x * a1) / (a2 - a1), (s.y * a2 - e.y * a1) / (a2 - a1));}double dissegtoseg(Line v) {return min(min(disPointToSeg(v.s), disPointToSeg(v.e)),min(v.disPointToSeg(s), v.disPointToSeg(e)));}
};bool cmp(Line v1, Line v2) {if (v1.e.x != v2.e.x) return v1.e.x < v2.e.x;return v1.s.x > v2.s.x;
}bool cmp1(Line v1, Line v2) { //最左上if (v1.s.x == v2.s.x) return v1.s.y > v2.s.y;return v1.s.x < v2.s.x;
}
bool cmp2(Line v1, Line v2) { //最右上if (v1.e.x == v2.e.x) return v1.e.y > v2.e.y;return v1.e.x > v2.e.x;
}double getdis(Line line, Line house, Line a, Line b) {Point p1 = a.e; Point p2 = b.s;Line l1 = Line(house.s, p1);Line l2 = Line(house.e, p2);Point c1 = l1.crossPoint(line);Point c2 = l2.crossPoint(line);
//     c1.output();
//     c2.output();double l = c1.x, r = c2.x;l = max(l, line.s.x); l = min(l, line.e.x);r = max(r, line.s.x); r = min(r, line.e.x);if (dcmp(l - r) >= 0) return 0;return r - l;
}int main() {double x1, x2, y;while (scanf("%lf%lf%lf", &x1, &x2, &y)) {if (x1 == 0 && x2 == 0 && y == 0) break;Line house = Line(Point(x1, y), Point(x2, y));scanf("%lf%lf%lf", &x1, &x2, &y);Line line = Line(Point(x1, y), Point(x2, y));int n;scanf("%d", &n);vector<Line> li;for (int i = 1; i <= n; i++) {scanf("%lf%lf%lf", &x1, &x2, &y);if (dcmp(y - house.e.y) >= 0) continue;li.push_back(Line(Point(x1, y), Point(x2, y)));}int cnt = li.size();if (cnt == 0) {printf("%.2f\n", line.e.x - line.s.x);continue;}vector<Line> nl;sort(li.begin(), li.end(), cmp);nl.push_back(li[0]);for (int i = 1; i < (int)li.size(); i++) {if (dcmp(li[i].e.x - li[i - 1].e.x) == 0) continue;nl.push_back(li[i]);}cnt = nl.size();double ans = 0;for (int i = 1; i < cnt; i++) {double tmp = getdis(line, house, nl[i - 1], nl[i]);
//            printf("%.2f\n", tmp);ans = max(ans, tmp);}//最左端特判sort(nl.begin(), nl.end(), cmp1);Line lp = Line(house.e, nl[0].s);Point cross = lp.crossPoint(line);ans = max(ans, cross.x - line.s.x);
//        printf("最左端: %.2f\n", cross.x - line.s.x);//最右端特判sort(nl.begin(), nl.end(), cmp2);lp = Line(house.s, nl[0].e);cross = lp.crossPoint(line);ans = max(ans, line.e.x - cross.x);
//        printf("最右端: %.2f\n", line.e.x - cross.x);if (dcmp(ans) == 0) printf("No View\n");else printf("%.2f\n", ans);}return 0;
}

寒假-第一周-几何-(点线关系的问题)相关推荐

  1. 项目实训第一周(车道线检测)

    项目实训我主要负责计算机视觉方面,识别出车道线并据此导航.相关内容也更新在我的个人博客上个人网站 相关介绍 车道线检测如果用传统方法,识别速度较慢,效果不够好,容易受到多种因素的干扰,因此我们打算开发 ...

  2. FJUT寒假第一周作业浮点数查寻题解

    二分强化--浮点数序列查询 TimeLimit:4000MS  MemoryLimit:128MB 64-bit integer IO format:%I64d Problem Description ...

  3. (前端学习)寒假第一周周报

    了解了一下前端学习的路线,我有点震惊,学习的东西真的很多很多,如下: 原来css也只是准备工作,不禁感慨任重而道远 附带一张我HTML和css的视频学习进度 这周学习完了HTML和css中的属性和一部 ...

  4. Hao Yin Jian 寒假第一周

    题目链接:https://vjudge.net/contest/147561#problem/A 题意:除法运算,abcde / fghij = n,从小到大输出,其中abcdefghij为0~9的不 ...

  5. NUIST2022级第一周集训

    #大一寒假第一周集训练! 主要内容:简单基础知识,模拟题.搜索题和部分CF智力题. 目的:锻炼码力,恢复训练,锻炼思维等.

  6. 慕课堂签到迟到怎么办_线上教学第一周:长安大学精品课程助力“云端课堂”...

    课下学生点播长安大学精品在线课程视频自学,课上与老师互动解决重点难点,实现空中翻转课堂.近几年学校陆续建设了85门精品在线开放课程资源,为我校的各类课程进行大规模线上线下混合式教学积累了宝贵的实践经验 ...

  7. XUPT_ACM2021寒假训练第一周练习记录

    试题链接:第一周训练题 - Virtual Judge 目录 A - 查成绩 B - 放暑假 C - 展开字符串 D - 回文数猜想 E - 宇航员 F - 买鸡问题 G - 水贴 H - 最小新整数 ...

  8. 深度学习笔记第二门课 改善深层神经网络 第一周:深度学习的实践层面

    本文是吴恩达老师的深度学习课程[1]笔记部分. 作者:黄海广[2] 主要编写人员:黄海广.林兴木(第四所有底稿,第五课第一二周,第三周前三节).祝彦森:(第三课所有底稿).贺志尧(第五课第三周底稿). ...

  9. 计算机图形学多边形填充代码_计算机图形学 Computer Graphics (第一周笔记及课件翻译)...

    本文使用 Zhihu On VSCode 创作并发布 注:本文部分内容源自于UDE课程 Computer Graphics(Prof. Dr. Jens Krüger),仅供本人自己学习与作为课程笔记 ...

最新文章

  1. combobox 怎么实现对listview的类别查询_通过 Django Pagination 实现简单分页
  2. Spring的常用注解,SpringMVC常用注解
  3. url模糊匹配优化_企业必备的网站SEO优化解决方案
  4. Java+Selenium 3.x 实现Web自动化 - 1.自动化准备
  5. 开课吧:从事数据分析必备能力有哪些?
  6. 微信公众平台回复音乐
  7. mysql如何查看表的大小_mysql 如何查看表的大小
  8. 惠普HP2132打印机 803墨盒的简单加墨方法
  9. 参考文献标引方式_参考文献的标注方法
  10. Ubuntu下键盘测试软件
  11. OSPF高等特性——Forwarding Address
  12. 关于DE405星历表的调用
  13. 关解决windows报错 Use `--location=global` instead. 和 found 0 vulnerabilities
  14. 冬季好去处七彩蝴蝶园,温暖如春彩蝶纷飞
  15. HM编码器代码阅读(15)——帧间预测之AMVP模式(三)xGetBlkBits函数
  16. Python+QyPt实现便利贴
  17. 浪涌-雷击浪涌的防护
  18. AutoLayout技术选型和应用
  19. Thymeleaf + Vue组件化开发
  20. 为什么我在繁忙的工作之余坚持写作?这几点是关键

热门文章

  1. 网络水军“反传销联盟”的自圆其说
  2. hibernate多对一查询
  3. W微信自动回复机器人
  4. activity启动模式 android,专题:详解Android组件Activity的启动模式singleTask_51CTO.COM
  5. jupyter端口被占用解决方法
  6. 物联网技术应用再扩展 可监测蜂巢状态
  7. 我在MIT人工智能研究实验室工作一年学到的 5 件事!
  8. word 图片文字环绕
  9. JavaScript18——触屏事件
  10. PCRE2-10.36编译(测试QtCreator的DEFINES用法)