随笔分类 -  数学/算术几何

摘要:设宽度为w,二分w。 1 #include <cstdio> 2 #include <cmath> 3 #include <algorithm> 4 5 #define eps 1e-6 6 7 using namespace std; 8 9 int main()10 {11 double x, y, c;12 while ( ~scanf( "%lf%lf%lf", &x, &y, &c ) )13 {14 double high = min( x, y );15 double low = 0.0;16 dou 阅读全文
posted @ 2013-06-15 23:44 冰鸮 阅读(356) 评论(0) 推荐(0)
摘要:我是求出来所有点的坐标用叉积算的面积……据说可以证明出来S△PQR = S△ABC/7 1 #include <cstdio> 2 #include <cmath> 3 4 struct Point 5 { 6 double x, y; 7 Point( double x = 0, double y = 0 ):x(x), y(y) { } 8 }; 9 10 Point operator+( Point A, Point B ) 11 { 12 return Point( A.x + B.x, A.y + B.y ); 13 } 14 15 P... 阅读全文
posted @ 2013-06-15 20:52 冰鸮 阅读(330) 评论(0) 推荐(0)
摘要:一开始直接用递归求后一个分数式的值,每求一步约分一次,过了小数据,大数据没过……后来发现是因为中间两个long long相乘溢出了……看了别人的代码才明白,只要思维稍微转化一下,这题就能变得很简单…… 1 #include <cstring> 2 #include <cstdlib> 3 #include <cstdio> 4 #include <algorithm> 5 6 using namespace std; 7 8 #define LL long long int 9 10 const int MAXN = 100;11 12 int 阅读全文
posted @ 2013-05-20 08:47 冰鸮 阅读(576) 评论(0) 推荐(0)
摘要:枚举两条竖线之间同时与这两条竖线相交的横线的个数cnt,这两条竖线之间能组成矩形的个数为:从cnt中任选两条横线的方案个数。将每两条竖线之间能组成矩形的个数加起来就是结果。 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <algorithm> 5 #include <vector> 6 7 using namespace std; 8 9 const int MAXN = 110;10 11 struct MyLine12 {13 in 阅读全文
posted @ 2013-05-18 23:11 冰鸮 阅读(230) 评论(0) 推荐(0)
摘要:参考这里:http://blog.csdn.net/q775968375/article/details/8828952大神说的没错,这跟建树没有半毛线的关系,就是一DFS。。。 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 5 #define LL long long int 6 7 const int MAXN = 1010; 8 9 struct node10 {11 LL val, BitWide;12 node(): val(0), BitWide(0) { }13 阅读全文
posted @ 2013-05-14 18:36 冰鸮 阅读(324) 评论(0) 推荐(0)
摘要:题意:给你一个能绕圆心转动的半径固定的半圆和N个点,问这个半圆最多能覆盖多少个点,半圆边界上的点也算在覆盖范围内。首先把半圆半径之外的点全部排除,枚举剩余所有点与圆心的连线。判断在同一侧的点有多少个。之前忽略的边界情况,WA一次。View Code 1 #include <cstdio> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cmath> 5 6 const int MAXN = 200; 7 const double EPS = 1e-9; 8 9 struct point1 阅读全文
posted @ 2013-05-01 11:13 冰鸮 阅读(254) 评论(0) 推荐(0)
摘要:简单的分解质因数约分 1 #include <cstdio> 2 #include <cstdlib> 3 #include <cstring> 4 5 const int MAXN = 10000 + 10; 6 7 bool Prime[MAXN]; 8 9 int aaa[5]; 10 int bbb[5]; 11 int num[2][MAXN]; 12 13 void GetPrime() 14 { 15 memset( Prime, true, sizeof(Prime) ); 16 Prime[0] = false ; 17 Pr... 阅读全文
posted @ 2012-09-26 22:36 冰鸮 阅读(259) 评论(0) 推荐(0)
摘要:题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=41&page=show_problem&problem=1150题意:求三块的面积 1 #include <cstdio> 2 #include <cmath> 3 4 const double PI = acos( -1.0 ); 5 6 int main() 7 { 8 double a; 9 while( scanf( "%lf", &a 阅读全文
posted @ 2012-08-22 20:01 冰鸮 阅读(467) 评论(0) 推荐(0)
摘要:题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=41&page=show_problem&problem=1121题意:给出两点坐标,用一条最短的线(曲线或者直线)连接起来,坐标系中原点处有一个半径为R的圆,连线不能穿过这个圆。分析:这题我WA了好几次,原因是把double的坐标搞成int了,o(╯□╰)o 1 #include <cstdio> 2 #include <cstdlib> 3 #include <cm 阅读全文
posted @ 2012-08-21 19:06 冰鸮 阅读(588) 评论(0) 推荐(0)
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3714这题我死活没读懂什么意思,后来还是别人讲的我才明白。题目:给出一组一元二次方程,用这一组一元二次方程生成一个新的函数F(x),求F(x)的最小值。x 对应F(x) 的值=这一组一元二次方程中yi = ai * x^2 + bi * x + ciy最大的那一个。分析:凹函数求极值,三分法。 1 #include <cstdio> 2 #include <cstring> 3 4 struct node 5 { 6 int a, b, c; 7 }; 8 9 const i 阅读全文
posted @ 2012-08-05 15:05 冰鸮 阅读(234) 评论(0) 推荐(0)
摘要:题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4562题目:给出一组数列和六种操作, 输出经过P次操作之后的数列。分析:因为P(1≤ P ≤ 109)很大,所以直接模拟会超时。也是看了解题报告之后才知道要用矩阵快速幂做。首先,把操作转化为矩阵乘法。因为 1×n 的矩阵乘以 n×n 的矩阵还是得到一个1×n 的矩阵,所以对数列的每一种操作都可以描述成一个n×n 的矩阵。然后再用矩阵快速幂得结果即可。快速幂模板:http://www.2cto.com/kf/201207/140 阅读全文
posted @ 2012-07-27 16:07 冰鸮 阅读(292) 评论(0) 推荐(0)
摘要:题目大意:给出一些建筑物的高度与宽度,求出一条最矮的抛物线运动轨迹,能够跨过所有的建筑物。输出初速度与水平方向的夹角,以及初速度的大小。重力加速度取9.8m/(s^2)思路:因为该抛物线过固定点(0,0)和(D,0)(D为所有建筑物宽度之和),故设抛物线方程为:y=A*x*(x-D)建立直角坐标系,得到最高的那一圈点的坐标。例如第二组样例:5010.52011.52510101507其对应坐标为:(10.500000,20.000000)(22.000000,25.000000)(32.000000,25.000000)(47.000000,10.000000)(54.000000,0.000 阅读全文
posted @ 2012-07-26 20:30 冰鸮 阅读(229) 评论(0) 推荐(0)