上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 41 下一页
摘要: 思路:首先,暴力会TLE,所以要把4个数分成2个和2个(关于这一点请阅读《挑战程序设计竞赛》)。注意到a*x1^2+b*x2^2的范围大小为2000000,我们不妨遍历前两个数,计算并记录在一个数组hash[]后,再遍历后两个数,并在hash[]中直接查找,这样复杂度就为O(n^2)(n=10... 阅读全文
posted @ 2015-12-20 16:21 StevenLuke 阅读(138) 评论(0) 推荐(0) 编辑
摘要: #include #include #define N 1000001using namespace std;bool cmp(const int& a, const int& b) { return a > b;}int main() { int n, m, i; int d[N]; whi... 阅读全文
posted @ 2015-12-20 16:09 StevenLuke 阅读(172) 评论(0) 推荐(0) 编辑
摘要: //据说使用线段树的 #include #include #define N 101int i, j, ans, buf[N][N];void print() { ans = 0; for(i=0; ibx) { tmp = ax; ax = bx; bx = tmp; } if... 阅读全文
posted @ 2015-12-20 14:52 StevenLuke 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 通过数据要判断俩点: 1、要保证每个点都相通,2、两点之间只有一条路径相通 方法: 1、判断连通图,即ans#include #define N 100001struct d{ int x; int y;}buf[N];int flag;int parent[N];bool judge[N];i... 阅读全文
posted @ 2015-12-19 15:40 StevenLuke 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 为啥ans要 -1 ? 未解。 #include #define N 1000struct d{ int x; int y;}buf[N];int parent[N];int find(int x) { return x==parent[x] ? x : find(parent[x]);}voi... 阅读全文
posted @ 2015-12-19 14:53 StevenLuke 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 并查集 for(i=0; i#define N 1001struct d{ int x; int y;}buf[N];int parent[N];int find(int x) { return x==parent[x] ? x : find(parent[x]);}void uni(int x... 阅读全文
posted @ 2015-12-19 14:28 StevenLuke 阅读(97) 评论(0) 推荐(0) 编辑
摘要: 思想实验是指:使用想象力去进行的实验,所做的都是在现实中无法做到(或现实未做到)的实验。例如爱因斯坦有关相对运动的著名思想实验,又例如在爱因斯坦和英费尔德合著的科普读物《物理之演进》中,就有一个实验要求读者想像一个平滑,无摩擦力的地面及球体进行实验,但这在现实(或暂时)是做不到的。思... 阅读全文
posted @ 2015-12-18 19:13 StevenLuke 阅读(260) 评论(0) 推荐(0) 编辑
摘要: 我知道我很水。 #include int main() { char c; int tmp = 0; while(scanf("%c", &c)) { if(c=='#') break; else if(c=='\n') { tmp = 0; } else if(c=='1') {... 阅读全文
posted @ 2015-12-18 12:46 StevenLuke 阅读(126) 评论(0) 推荐(0) 编辑
摘要: 求多边形重心的题目大致有这么几种: 1、质量集中在顶点上 n个顶点坐标为(xi,yi),质量为mi,则重心 X = ∑( xi×mi ) / ∑mi Y = ∑( yi×mi ) / ∑mi 特殊地,若每个点的质量相同,则 X = ∑xi / n Y = ∑yi... 阅读全文
posted @ 2015-12-16 14:15 StevenLuke 阅读(96) 评论(0) 推荐(0) 编辑
摘要: S(abc) = (|ab|*|ac|*sinΘ) / 2 = |ab| × |ac| / 2//叉积 #include struct point { double x1, y1, x2, y2;}buf[101];int judge(int i, int j) { //叉积 int f1=... 阅读全文
posted @ 2015-12-16 13:18 StevenLuke 阅读(112) 评论(0) 推荐(0) 编辑
上一页 1 ··· 20 21 22 23 24 25 26 27 28 ··· 41 下一页