Số bài đã giải: 30
Hạng điểm: #6888
Tổng điểm:
6,75
Đóng góp:
0
Đã tham gia 3 kỳ thi
Hạng rating: #1958
Rating: 1508
Min. rating: 1403
Max rating: 1508
Từ Trường THPT chuyên Đại học Sư phạm Hà Nội, Trường THPT Chuyên Chu Văn An, Hà Nội
Thông tin
#include <bits/stdc++.h>
#define head ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); freopen("dtdt.inp","r",stdin); freopen("dtdt.out","w",stdout);
using namespace std;
struct diem {
int x, y;
} a, b, c, d;
double tdt(diem A, diem B, diem C) {
return ((A.y - B.y) * C.x + (B.x - A.x) * C.y + A.x * B.y - A.y * B.x);
}
int kt() {
if(tdt(c, d, a) == 0 && tdt(c, d, b) == 0) return 3;
if(tdt(c, d, a) == 0 || tdt(c, d, b) == 0 || tdt(c, d, a) * tdt(c, d, b) < 0) return 1;
if(a.y - b.y == c.y - d.y) return 2;
return 4;
}
int main() {
head;
cin >> a.x >> a.y >> b.x >> b.y >> c.x >> c.y >> d.x >> d.y;
cout << kt();
return 0;
}
#include <bits/stdc++.h>
#define int long long
using namespace std;
struct Tron {
int x, y, r;
} h[1001];
int n, cha[1001];
int tim(int u) {
return (u == cha[u]) ? u : cha[u] = tim(cha[u]);
}
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
freopen("cachtron.inp", "r", stdin);
freopen("cachtron.out", "w", stdout);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> h[i].x >> h[i].y >> h[i].r;
cha[i] = i;
}
for (int i = 1; i <= n; ++i) {
for (int j = i + 1; j <= n; ++j) {
int dx = h[i].x - h[j].x;
int dy = h[i].y - h[j].y;
int kc2 = dx * dx + dy * dy;
int tongR = h[i].r + h[j].r;
if (kc2 <= tongR * tongR) {
int a = tim(i), b = tim(j);
if (a != b) cha[a] = b;
}
}
}
set<int> nhom;
for (int i = 1; i <= n; ++i) nhom.insert(tim(i));
cout << nhom.size();
return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
freopen("HAIHCN.INP", "r", stdin);
freopen("HAIHCN.OUT", "w", stdout);
int x1, y1, x2, y2, x3, y3, x4, y4;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
int s = (x2 - x1) * (y2 - y1) + (x4 - x3) * (y4 - y3);
int dx = max(0, min(x2, x4) - max(x1, x3));
int dy = max(0, min(y2, y4) - max(y1, y3));
cout << s - dx * dy;
}
#include <bits/stdc++.h>
using namespace std;
struct P { double x, y; };
struct L { double a, b, c; };
L makeline(P p, P q) { return {q.y - p.y, p.x - q.x, q.x * p.y - p.x * q.y}; }
P cross(L u, L v) {
double d = u.a * v.b - v.a * u.b;
if (fabs(d) < 1e-9) return {NAN, NAN};
return {(u.b * v.c - v.b * u.c) / d, (v.a * u.c - u.a * v.c) / d};
}
bool on(P p, P a, P b) {
double cp = (p.x - a.x) * (b.y - a.y) - (p.y - a.y) * (b.x - a.x);
if (fabs(cp) > 1e-9) return false;
double dot = (p.x - a.x) * (b.x - a.x) + (p.y - a.y) * (b.y - a.y);
double len = pow(b.x - a.x, 2) + pow(b.y - a.y, 2);
return dot >= 0 && dot <= len;
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
freopen("TAMGIACDT.INP", "r", stdin);
freopen("TAMGIACDT.OUT", "w", stdout);
P t[3], d, e;
for (auto &p : t) cin >> p.x >> p.y;
cin >> d.x >> d.y >> e.x >> e.y;
L l = makeline(d, e);
vector<P> pts;
for (int i = 0; i < 3; ++i) {
P p = cross(l, makeline(t[i], t[(i+1)%3]));
if (!isnan(p.x) && on(p, t[i], t[(i+1)%3])) pts.push_back(p);
}
sort(pts.begin(), pts.end(), [](P a, P b) {
return tie(a.x, a.y) < tie(b.x, b.y);
});
pts.erase(unique(pts.begin(), pts.end(), [](P a, P b) {
return hypot(a.x - b.x, a.y - b.y) < 1e-9;
}), pts.end());
if (pts.size() < 2) cout << -1;
else cout << fixed << setprecision(3) << hypot(pts[0].x - pts[1].x, pts[0].y - pts[1].y);
}
#include <bits/stdc++.h>
#define head ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); freopen("Dagiac.inp","r",stdin); freopen("Dagiac.out","w",stdout);
using namespace std;
struct diem {
int x, y;
} a[1005];
int n;
double tdt(diem A, diem B, diem C) {
return ((A.y - B.y) * C.x + (B.x - A.x) * C.y + A.x * B.y - A.y * B.x);
}
double tdtich(int n) {
double s = 0;
for(int i = 1; i <= n; ++i) s += (a[i].x - a[i+1].x) * (a[i].y + a[i+1].y) / 2.0;
//s += (a[i].y - a[i+1].y) * (a[i].x + a[i+1].x) / 2;
return abs(s);
}
bool loi(int x, int y) {
for(int i = 1; i <= n; i++) if(tdt(a[x], a[y], a[i]) * tdt(a[x], a[y], a[i + 1]) < 0) return 0;
return 1;
}
bool cat(int x, int y) {
return ((tdt(a[x], a[x + 1], a[y]) * tdt(a[x], a[x + 1], a[y + 1]) < 0) && (tdt(a[y], a[y + 1], a[x]) * tdt(a[y], a[y + 1], a[x + 1]) < 0));
}
bool tucat() {
for(int i = 1; i <= n - 1; i++) for(int j = i + 1; j <= n; j++) if(cat(i, j)) return 1;
return 0;
}
int main() {
head;
cout.precision(3);
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i].x >> a[i].y;
a[n + 1] = a[1];
for(int i = 1; i <= n; ++i)
if(!loi(i, i + 1)) {
if(tucat()) cout << 3;
else cout << 2 << endl << fixed << tdtich(n);
return 0;
}
cout << 1 << endl << fixed << tdtich(n);
return 0;
}
#include <bits/stdc++.h>
#define head ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); freopen("Baoloi.inp","r",stdin); freopen("Baoloi.out","w",stdout);
using namespace std;
const int nm = 1e4 + 1;
struct diem {
double x, y;
} a[nm];
bool kt = 1, f[nm];
int n;
vector <diem> b;
double dd(diem A, diem B) {
return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
}
bool cmp(diem a, diem b) {
return a.y < b.y;
}
bool cungphia(diem d1, diem d2) {
int j;
double kq = 0, a1 = d1.y - d2.y, b1 = d2.x - d1.x, c1 = d1.x * d2.y - d2.x * d1.y;
for(j = 1; j <= n and kq == 0; j++) kq = a1 * a[j].x + b1 * a[j].y + c1;
--j;
if(kq < 0) {
for(int k = j + 1; k <= n; k++) if(a1 * a[k].x + b1 * a[k].y + c1 > 0) return 0;
}
else {
for(int k = j + 1; k <= n; k++) if(a1 * a[k].x + b1 * a[k].y + c1 < 0) return 0;
}
return 1;
}
void cvdt() {
cout.precision(3);
double c = 0, s = 0;
for(int i = 0; i < b.size() - 1; i++) {
c += dd(b[i], b[i + 1]);
s += (b[i].x - b[i + 1].x) * (b[i].y + b[i + 1].y) / 2;
}
cout << fixed << c << ' ' << abs(s);
}
int main() {
head;
cin >> n;
for(int i = 1; i <= n; ++i) cin >> a[i].x >> a[i].y;
sort(a + 1, a + 1 + n, cmp);
b.push_back(a[1]); f[1] = 1;
while(kt) {
kt = 0;
for(int i = 2; i <= n; ++i)
if(!f[i] and cungphia(b[b.size() - 1], a[i])) {
b.push_back(a[i]);
f[i] = 1;
kt = 1;
}
}
cout << b.size() << ' ';
b.push_back(a[1]);
cvdt();
return 0;
}
Huy hiệu
Người dùng này không có huy hiệu nào.Lịch sử rating
, #