Skip to content
Snippets Groups Projects
Commit 81f05507 authored by Bruno Freitas Tissei's avatar Bruno Freitas Tissei
Browse files

Add geometry functions

parent e9fc13d1
No related branches found
No related tags found
1 merge request!2Refactor
/**
* Geometry functions
*/
struct Vector {
double x, y;
Vector(double x, double y) : x(x), y(y) {}
double dot_product(Vector v) { return x * v.x + y * v.y; }
double cross_product(Vector v) { return x * v.y - v.x * y; }
/**
* Returns angle between this and v.
*/
double angle(Vector v) {
// atan2(y, x) is in the range [-180,180]. To get [0, 360],
// atan2(-y, -x) + 180 is used
return ((atan2(-cross_product(v), -dot_product(v)) * 180.0) / M_PI) + 180.0;
}
};
......@@ -19,7 +19,6 @@ using namespace std;
using ll = long long;
using ii = pair<int,int>;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
......@@ -27,6 +26,7 @@ int main() {
string s; cin >> s;
s.erase(s.begin() + s.size() - 3);
stringstream x(s);
int r; x >> r;
cout << 36000 / __gcd(36000, r) << ende;
......
......@@ -34,17 +34,16 @@ int main() {
if (pref.back() % 2)
return cout << "N" << ende, 0;
int beg = 0;
vector<ii> found;
int beg = 0, ans = 0;
for (int i = 0; i < n; ++i) {
while (beg < i && pref[i] - pref[beg] > pref.back() / 2)
beg++;
if (pref[i] - pref[beg] == (pref.back() / 2))
found.pb(ii(beg, i));
ans++;
}
if (found.size() >= 2)
if (ans >= 2)
cout << "Y" << ende;
else
cout << "N" << ende;
......
......@@ -25,8 +25,7 @@ int d[MAX], c[MAX];
int dp[MAX][6][123];
int fix(int x) {
if (x > 120) return 121;
else return x;
return min(x, 121);
}
int solve(int i, int state, int mi) {
......
n = int(input())
every = []
for i in range(n):
s = input()
x = s.split('@')
x = input().split('@')
every += [ x[0].split('+')[0].replace('.','') + x[1] ]
print(len(set(every)))
#include <bits/stdc++.h>
#define EPS 1e-6
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define llinf 0x3f3f3f3f3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define ende '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))
using namespace std;
using ll = long long;
using ii = pair<int,int>;
struct Point {
double x, y;
Point() {}
Point(double x, double y) : x(x), y(y) {}
Point operator-(Point a) { return Point(x - a.x, y - a.y); }
};
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
ll n; cin >> n;
vector<Point> v(n);
for (auto &i : v)
cin >> i.x >> i.y;
ll ans = (n * (n - 1LL) * (n - 2LL)) / 6LL;
for (int i = 0; i < n; ++i) {
ll l = i + 1, r = i + n - 1;
for (int j = 0; j < 20; ++j) {
ll m = (l + r) / 2;
Point a = v[(i+1)%n] - v[i];
Point b = v[(m+1)%n] - v[m%n];
double ang = (atan2(-(a.x*b.y - a.y*b.x), -(a.x*b.x + a.y*b.y)) * 180.0) / M_PI + 180.0;
if (ang > 180.0)
r = m;
else
l = m;
}
ans -= ((l - i) * (l - i - 1LL)) / 2LL;
}
cout << ans << ende;
return 0;
}
......@@ -107,7 +107,9 @@ int main() {
for (auto i : que) {
while (curr >= 0 && primes[curr] > i.fi.fi) {
for (int j = primes[curr]; j <= N; j += primes[curr])
if (query(j, j) != 0) update(j, -1);
if (query(j, j) != 0)
update(j, -1);
curr--;
}
......
......@@ -19,21 +19,19 @@ using namespace std;
using ll = long long;
using ii = pair<int,int>;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n; cin >> n;
int past = 0;
int ans = 0;
int past = 0, ans = 0;
for (int i = 0; i < n; ++i) {
int x; cin >> x;
if (x > past)
ans++;
past = x;
}
cout << ans << ende;
cout << ans << ende;
return 0;
}
361391
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment