- 博客(24)
- 资源 (3)
- 收藏
- 关注
原创 poj2947
高斯消元法模版题,但套模版没用。。先回顾一下线性代数的知识。若要求解如下方程:首先,其系数矩阵为然后,其增广矩阵为:然后若要求解这个方程,首先将第一行第一个元素化为1,即:第一行乘以1/3。
2013-08-16 16:40:17 1740 1
原创 HDU4667(有错)
正规的做法是找切点。三角形三个顶点分别对圆作切线,然后求切点(2个)。两圆之间也要求切点(4个)。扯淡了这就。。麻烦的要命。。下面是写了一半的代码。。void process_circle(point p, point o, double r, point &intersect1, point &intersect2){ point
2013-08-15 13:48:11 1232
原创 poj3227
很简单的一个题,判判斜率求求交点就搞定了,可是搞了一上午。。#include #include #include using namespace std;#define eps 1e-8struct point{ double x, y;}p[1010];double dist(point a,
2013-08-13 16:16:09 1037
原创 poj2031
最小生成树。边权=AB圆心距离-A半径-B半径。#include #include #include using namespace std;#define eps 1e-8#define zero(x) (((x)>0?(x):-(x))#define MAXN 200#define inf 1000000000
2013-08-12 09:49:57 1377 2
原创 poj2115
构造出模线性方程c * x = b - a mod (2 ^ k)很容易解。利用LRJ书上的方法。#include using namespace std;#define LL long long intLL ext_gcd(LL a, LL b, LL& x, LL& y){ LL t, ret; if (!b){ x = 1, y = 0; return
2013-08-09 16:41:14 1404 1
原创 poj2635
这个题主要是要学会高精度求模。思路有二,首先转化成千进制,然后利用“同余模定理”,或称“同余定理”。比较实用的几条规律:例如,想求123%4,可以这么操作(100%4+20%4+3%4)%4。利用了性质1、性质3。为何把它化作千进制,因为利用性质三,可知其是正确的。化作千进制,求模就变成了不超过1000的数的模,虽然次数增多,但是可以求解大数的模。#include
2013-08-09 14:41:13 1271
原创 poj1006
数论跪了三天。。这个题不难得到(n+d)%23=p; (n+d)%28=e; (n+d)%33=i 如何求解?首先介绍一个所谓“逆”的概念。给定整数a,有(a,m)=1,称ax=1(mod m)的一个解叫做a模m的逆。下面给出求逆的程序。#include #include using namespace std;typedef long long LL;
2013-08-09 11:01:57 1975 1
原创 poj1942
高中就见过。注意组合数优化和7/2=3这种情况#include #include using namespace std;#define ULL unsigned long long intint main(){ ULL a, b; while (cin >> a >> b && (a || b)) { if (b > a) swap(a, b); ULL s =
2013-08-07 10:01:02 1257 3
原创 poj2524
说来惭愧啊。。现在才会并查集。我竟然给我妈妈讲明白并查集怎么回事了- -#define _CRT_SECURE_NO_WARNINGS#include using namespace std;#define maxx 50010int set[maxx];int find(int x) { return x == set[x] ? x : (set[x] = fin
2013-08-05 23:21:07 2120 4
原创 poj1068
#include#includeusing namespace std;int a[101];int main(){ int n,m,bf,x,t; cin>>t; while(t--) { cin>>n; bf=0; memset(a,0,sizeof(a)); while(n--)
2013-08-05 20:27:08 82
原创 poj3295
本题虽然简单,但是利用了编译原理里面的自顶向下方法来设计语法树,递归求解。例如:对于逻辑表达式A&B|C,得到以下输出 A B C A&B|C 0 0 0 0 0 0 1 1 0 1 0 0 0 1 1 1 1 0 0 0 1 0 1 1 1 1 0 1 1 1 1 1逻辑表达式支持:常量(只有0
2013-08-05 15:28:31 1738
原创 poj1753
复杂度不高#include #include #include using namespace std;int array[5][5],t[5][5];int bit[5];void Getbit(int i){ int t=4; while(i!=0) { bit[t]=i%2; i=i/2; t--;
2013-08-05 10:02:30 1021
原创 poj2007
极角排序,其实是叉乘排序#include #include #include #include using namespace std;#define eps 1e-8struct point{ double x, y;} s;double getangle(point a){ return atan2(a.y, a.x);}double xmult(poi
2013-08-03 20:14:47 1364 1
原创 快速组合数
递推公式很简单:C(n,k+1) = C(n,k) * (n-k) / (k + 1)方法很暴力经测,C(2000,1000)可以求出,C(2000,0)到C(2000,2000)所用时间仅需0.2s#include #include #include #include #include #include using namespace std;const int
2013-08-03 11:10:34 1300
原创 poj2966(有问题)
仍然是多边形与线段求交(不规范),然后加最短路。边权:如果相交则inf,如果不相交则其直线距离。不知道为什么错,想出了几个脑残图形,都对了。对应的测试数据:1 0 1 460 01 12 02 41 30 40 0 5 471 05 25 43 41 4-2 2-1 00 0 2 682 04 24 42 60 42 4
2013-08-03 09:45:55 1281 3
原创 poj1556
计算几何+最短路最短路是套的模版。。= =毕竟不是自己写的。。模版上的点竟然是从0开始的。难在建图。图中,比如2和12点,其间如果没有任何线段阻挡,那么边权是他们的直线距离,如果有线段阻挡,边权是inf。枚举每两个点,用其组成的线段与其他所有线段判断,如果相交则边权inf,如果不相交距离是其直线距离。#include #include #define eps 1e
2013-08-02 15:51:35 1488 1
原创 poj2420
模拟退火算法,其实不如说随机化变步长的贪心,向四周搜索,如果碰到更小的则把它作为更优解。本题代码中费马点部分可作为模版使用。#include #include #include #define MAX_NUM 128struct point{ double x; double y;};double distance(point p1, point p2){
2013-08-01 21:27:47 1963 2
原创 Computational Geometry Template_Convex Hull
#define eps 1e-8#define zero(x) (((x)>0?(x):-(x))<eps)struct point{double x,y;};//计算cross product (P1-P0)x(P2-P0)double xmult(point p1,point p2,point p0){ return (p1.x-p0.x)*(p2.y-p0.
2013-08-01 21:18:00 811
原创 poj3348
凸包入门,求多边形面积多边形面积无非就是些三角形的面积之和,然后以起点叉乘积除以二即可。#include #include #include #define eps 1e-8#define zero(x) (((x)>0?(x):-(x))<eps)#define _sign(x) ((x)>eps?1:((x)<-eps?2:0))struct point{in
2013-08-01 20:18:18 983
原创 poj2354
计算球面距离,度分秒转换。#include #include #include #define pi acos(-1.0)//计算圆心角lat表示纬度,-90<=w<=90,lng表示经度//返回两点所在大圆劣弧对应圆心角,0<=angle<=pidouble angle(double lng1, double lat1, double lng2, double lat2){
2013-08-01 15:01:31 1161
原创 poj1673
所谓Exocenter就是垂心。不难证明。#include #include #include struct point{ double x, y; };struct line{ point a, b; };double distance(point p1, point p2){ return sqrt((p1.x - p2.x)*(p1.x - p2.x) + (p1.y -
2013-08-01 14:29:37 964
原创 poj1329
三角形外心及外接圆半径三角形三边为 a、b、c半周长 p=(a+b+c)/2三角形面积 S=√[p(p-a)(p-b)(p-c)] (海伦公式)内切圆半径 r = S/p =√[(p-a)(p-b)(p-c)/p] = ½√[(-a+b+c)(a-b+c)(a+b-c)/(a
2013-08-01 10:59:05 992
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人