计算几何
tips
注意舍入方式(0.5 的舍入方向);防止输出-0.
几何题注意多测试不对称数据.
整数几何注意 xmult 和 dmult 是否会出界; 符点几何注意 eps 的使用.
避免使用斜率;注意除数是否会为 0.
公式一定要化简后再代入.
判断同一个 2*PI 域内两角度差应该是 abs(a1-a2)<beta||abs(a1-a2)>pi+pi-beta;
相等应该是abs(a1-a2)<eps||abs(a1-a2)>pi+pi-eps;
需要的话尽量使用 atan2,注意:atan2(0,0)=0, atan2(1,0)=pi/2,atan2(-1,0)=-pi/2,atan2(0,1)=0,atan2(0,-1)=pi.
cross product = |u|*|v|sin(a) dot product = |u||v|*cos(a)
(P1-P0)x(P2-P0)结果的意义:
正: <P0,P1>在&l ...
Atcoder Beginner Contest 315(A-F)
A tcdr123456789101112131415#include<bits/stdc++.h>using namespace std;int main(){ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); string s; cin >> s; for(int i = 0; i < s.size(); i++) { if(s[i] == 'a' || s[i] == 'e' || s[i] == 'o' || s[i] == 'u' || s[i] == 'i') continue; cout << s[i]; } return 0;}
B The Middle Day12345678910111213141516171819202122232425#include<bits/stdc++.h>using namespace std;i ...
Codeforces Round 894 (Div. 3)
A Gift Carpet模拟,按列遍历一个一个选
12345678910111213141516171819202122232425262728293031323334#include<bits/stdc++.h>using namespace std;const string s = "vika";void solve(){ int n, m; cin >> n >> m; vector<string> g(m); for(int i = 0; i < n; i++) { for(int j = 0; j < m; j++) { char c; cin >> c; g[j] += c; } } int ans = 0; for(int i = 0; i < m && ans ...
Atcoder Beginner Contest 314
A 3.14code1234567891011#include<bits/stdc++.h>using namespace std;int main(){ string s = "1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679"; int n; cin >> n; cout << "3." << s.substr(0,n); return 0;}
B Roulette找到目标,排序输出
123456789101112131415161718192021222324252627282930313233343536373839404142#include<bits/stdc++.h>using namespace std;int c[110], b[110][40];int main(){ int n; cin ...
HDU-4578 Transformation
TransformationYuanfang is puzzled with the question below:There are n integers, a1, a2, …, an. The initial values of them are 0. There are four kinds of operations.Operation 1: Add c to each number between ax and ay inclusive. In other words, do transformation ak<—ak+c, k = x,x+1,…,y.Operation 2: Multiply c to each number between ax and ay inclusive. In other words, do transformation ak<—ak×c, k = x,x+1,…,y.Operation 3: Change the numbers between ax and ay to c, inclusive. In oth ...
HDU-4614 Vases and Flowers
Vases and Flowers Alice is so popular that she can receive many flowers everyday. She has N vases numbered from 0 to N-1. When she receive some flowers, she will try to put them in the vases, one flower in one vase. She randomly choose the vase A and try to put a flower in the vase. If the there is no flower in the vase, she will put a flower in it, otherwise she skip this vase. And then she will try put in the vase A+1, A+2, …, N-1, until there is no flower left or she has tried the vase N-1. ...