- 博客(11)
- 收藏
- 关注
原创 CodeForces Manthan, Codefest 16 B A Trivial Problem 二分
被cmath里的pow函数坑了,,,不明白为什么。。。 找到了那个WA的test,我的VS2013运行就没问题,但是在评测机上就有问题。。。 官方的思路是二分,不过我的不是,,,有时间再贴讲解吧,,感觉我的思路也没什么意思 代码: #include #include #include #include #include #include #include #inclu
2016-02-29 00:59:45 380
原创 HDU 5444 二叉树
给的序列是二叉树的中序遍历,然后把所有数从小到大排列是该二叉树的先序遍历 然后可以唯一确定这棵二叉树,然后求一下就好,它的任何一个子树,满足左 找了一个网上的根据先序和中序确定二叉树的版。。。 代码: #include #include #include using namespace std; #define N 1005 char path[N]; struct Node
2016-02-28 22:25:15 464
原创 HDU 5441 离线处理+并查集
并查集+离线处理 代码: #include #include #include #include #include #include using namespace std; #define maxm 100002 #define maxn 20002 #define maxq 5002 int set[maxn]; int size[maxn];//结点数 struct
2016-02-28 22:19:32 324
原创 CodeForces Manthan, Codefest 16 A Ebony and Ivory 扩展欧几里德(其实暴力直接搞就可以)
求是否存在两个非负系数x,y,使得ax+by=c。a,b属于[1,100],c属于[1,10000]。 扩展欧几里德求不定方程 代码: #include #include #include #include #include #include #include using namespace std; int gcd(int a, int b)//普通方法 { int m,
2016-02-27 19:49:33 415
原创 math数学部分
gcd最大公约数(欧几里德算法,迭代形式) int gcd(int a,int b)//普通方法 { int m,n,r; m=a>=b?a:b;//m>=n n=a<b?a:b; r=m%n; while(r!=0) { m=n; n=r; r=m%n; } return n; } lcm最小公倍数 int lcm(int a,int b) { re
2016-02-26 00:29:27 536
原创 Disjoint-Set并查集
路径压缩+启发式合并,应该是最快的了吧 #include #include #include using namespace std; #define maxn 100 int set[maxn]; int size[maxn];//结点数 void init_set() { for(int i=0;i<maxn;++i) { set[i]=i; size[
2016-02-26 00:24:21 346
转载 BigInteger大整数类高精度
代码来自刘汝佳的《算法竞赛入门经典》(第二版) #include #include #include #include #include #include #include using namespace std; struct BigInteger { static const int BASE = 100000000; static const int WIDTH =
2016-02-26 00:20:55 2249
原创 小紫书 4-5 UVA 1590 IP Networks
题解: 代码: #include #include #include #include #include using namespace std; int m, n = 32; bool net[32], add[32]; void str_to_add(char str[20], int x) { for (int i = 0, j = 0, tmp = 0; j < 2
2016-02-23 00:48:26 428
原创 小紫书 4-4 UVA 253 Cube painting
额,这题应该是枚举,一开始想的总不是很好,窝的确是一直连枚举都不会的渣渣 做法非原创,把每个面作为最上面的面,这样就能确定上下两个面了,一共是6种,然后每种里,竖立的这四个面可以旋转四次,所以一共是6*4=24种情况,依次枚举即可。 代码: #include #include #include #include #include using namespace std; c
2016-02-22 12:26:03 299
原创 小紫书 4-3 UVA 220 Othello
代码: #include #include #include #include #include #include #include using namespace std; char player; char board[12][12]; int drct[2][8] = { 1, 0, 1, 1, -1, 0, -1, -1 , 0, 1, -1, 1, 0, -1, 1, -
2016-02-21 22:31:42 392
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人