自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(68)
  • 收藏
  • 关注

转载 计算机网络二进制反码求和校验算法

原文链接:http://blog.chinaunix.net/uid-26758209-id-3146230.html校验和算法    经常看计算机网络相关的书时,每次看到关于IP或者是UDP报头校验和时,都是一笑而过,以为相当简单的东西,不就是16bit数据的相加吗!最近在学习Ping命令的源待时,看到里面有关于校验和的算法。一头雾水,后来查找资料,看到校验和是16bit字的

2017-12-24 12:01:53 8179 1

原创 codeforce898E Squares and not squares (round #451 div 2)

题目询问将一组数变成一半为平方数,一半为非平方数 的最少步数。初始化所有的平方值,注意要开到比1e9大的第一个数。然后读取,把所有值与其最近的平方数(lower_bound)之差push到一个优先队列里。并统计平方数的个数S 和0的个数Z(因为0需要改变两次才能到一个非平方数)。然后根据S和Z判断输出,详见代码。#include using names

2017-12-17 09:16:40 281

原创 CodeForce896 B. Ithea Plays With Chtholly

#include using namespace std;const int maxn = 1050 ;int n , m , c , temp ;int arr[maxn] ;int main(){ int num = 0 ; scanf("%d %d %d" , &n , &m , &c) ; memset(arr , -1 , sizeof(arr))

2017-12-16 18:56:34 296

原创 codeforces 896A dfs

Nephren gives a riddle题目要求在一个无限迭代的字符串中在第n层找到第k个字母。f(x) = sb +   f(x - 1) + sc  + f(x - 1) + sd 预处理出不超过范围的最大层。则下一层大于这一层的两倍。dfs如果在预处理层之内,且k大于该层长度,则返回   ‘.’如果在第0层,返回原串位置如果在sb之内,返回sb的字母如果在

2017-12-15 12:03:44 253

原创 codeforces 896C

由于是随机数生成,所以可以用map或者set的平衡树维护。对于各类操作,暴力即可(看了题解,一口老血吐出来)注意操作2是,删除后合并即可。注意如果数在某个区间内,直接map  tree[A] = B ,即new了该结点,还有注意upper_bound,和lower_bound返回的指针。#include using namespace std;typede

2017-12-11 20:18:35 444

原创 hdu 6223 Infinite Fraction Path BFS

这题做的太闹心了,把vector爆了。。。debug了2个小时。。虽然vector的maxsize有这么大,我算的也不会爆。但如果init函数写成如下就会wa,希望路过的能指点下:save.clear() ; int temp_max = '0' ; for(int i = 0 ; i < n ; i ++ ){ if(read[i] > t

2017-11-29 10:04:25 367

原创 树链剖分模板

样题链接http://www.spoj.com/problems/QTREE/模板如下:#include using namespace std ;typedef long long ll ;const int maxn = 1e4 + 5 ;int deep[maxn] ;int size[maxn] ;int father[maxn] ;int son[m

2017-11-26 18:47:05 192

原创 Codeforces #446 (Div. 2) 题解

A Greed 注意long long#include using namespace std;const int maxn = 100005 ;typedef long long ll ;ll a[maxn] ;ll b[maxn] ;int main(){ int n ; while(~ scanf("%d" , &n) ){ priority_

2017-11-19 19:16:25 295

原创 codeforces 878C 及部分set的用法

参考的题解:http://blog.csdn.net/weixin_37517391/article/details/78374840非常清楚与详尽,点赞#include using namespace std ;const int maxn = 15 ;struct node{ int cap ; int num ; int max_vector

2017-11-15 23:59:30 492

原创 codeforce 449 B 最短路

codeforce 449 B题意: 一个无向图,给你两种边,一种边可以删除(全部从起点出发),问在不改变原来所有点最短路的情况下,能删最多多少条边。解: 由于可删边都从起点出发,松弛时候也不会返回起点,所以只需要建立从起点到另一点的单向边,然后进行一遍spfa,初始所有点的最短路的值,然后判断所有可删边,如果该边长比最短路的值长即可删,如果相等,再对到达的点进行判断,看能否由

2017-10-29 00:09:03 418

原创 poj 3613 floyd

题意: 求进过路径数量为k的已知起点的最短路 ;先进行在线离散化。然后Floyd  矩阵快速幂。注意 如果结构体中数组大小开太大 (大概极限是350乘350)的话不能动态使用,就是将结构体导入导出函数,需要在外部声明一个常量的结构体,对其进行改变。//#include #include #include #include #include #include us

2017-10-29 00:04:58 270

原创 poj 1201 差分约束

1431ms  将所有约束条件的边建立,然后spfa输出最大值与最小值之差//#include #include #include #include #include #include using namespace std ;const int inf = 0x3f3f3f3f ;const int maxn = 50005 ;struct edge{ in

2017-10-28 23:59:38 205

原创 汉密尔顿图

#include#include#include#includeusing namespace std;#define maxn 1111int n,ans[maxn],vis[maxn];bool M[maxn][maxn];void reverse(int l,int r){ while(l<r) { swap(ans[l],ans[r]);

2017-10-27 20:25:19 1534

原创 同余最短路

第一个是判断 给你 n 个数,问a 是否能由求和求到,求出每一个数%最小的数的最小出现值,比较大小即可,用最短路建图#include using namespace std;typedef long long ll ;const int INF = 0x3f3f3f3f ;ll save[5050] ;ll dis[50050] ;ll point , road , mod ;

2017-10-27 20:21:51 648

原创 codeforce 543 B 最短路

预处理所有最短路。然后暴力所有区间,check是否满足条件然后进行松弛操作#include using namespace std ;typedef long long ll ;const int inf = 0x3f3f3f3f ;const int maxn = 3050 ;struct edge{ int u , v ; int w ;};vector

2017-10-27 20:18:28 391

原创 codeforce 416 E floyd

最短路求最短路经过的所有路径,一般点不多,都可以暴力所有区间,check是不是最短路的一部分注意 这里的cnt是最后一层的,而不是所有的#include using namespace std ;typedef long long ll ;const int inf = 0x3f3f3f3f ;const int maxn = 550 ;int edge[maxn][max

2017-10-27 20:15:15 383

原创 codeforce 623 A

因为只有a b c , b 和其他都联通, 从这里突破#include using namespace std ;typedef long long ll ;const int inf = 0x3f3f3f3f ;const int maxn = 550 ;bool g[maxn][maxn] ;int deg[maxn] ;bool vis[maxn] ;char

2017-10-27 20:08:57 294

原创 codeforces 878 A short programme

老毕教我了思路,然而比赛时还时没敲完,赛后debug15分钟ac思路因为所有位运算的数小于2的10次方,所以我们把每一此操作对应到每一位上,然后对不必要的操作化简,比如说 (这里都是指每一位的)&0 |1 == | 1 , | 1 & 0 == & 0.。。注意 ^1^1 = 无操作。。#include using namespace std ;typedef lo

2017-10-27 19:04:09 387

原创 计算客 - 热爱工作的蒜蒜 - spfa

只有100个点,最短路预处理所有 i 到 j 的最短路,松弛操作时同时更新在最短路条件下该段路经过的避雨路段数(即路长) 。然后暴力所有区间,O(n2)判断是否起点+该区间+到终点的路长小于 要求            p = dis[1][i] + dis[i][j] + dis[j][n] ;            q = num[1][i] + num[i][j] + num

2017-10-25 10:17:27 516 2

原创 acm icpc 沈阳站简记

这是第一次参与区域赛,虽然作为主办方,是打星参赛,但还是感到很兴奋。第一天,打星的队伍的电脑都是自己带的,然而一开始竟然没有人通知我们队伍,而我们早上坐了最早的8点钟的校车,一个非常冷的早晨,路上树叶泛黄,满树雀鸣,进入报道现场,说明是东北大学参赛队伍,志愿者表示很惊讶,签到单上没有东北大学,表示你是哪个学校的,没听说过。。。然后一路苦等,等到两点钟,满心期待打算参

2017-10-24 23:24:02 436

原创 Ivan comes again set用法

set 用法#include using namespace std;int main(){ pairp; int n; char str[10]; int c=1; while(cin>>n&&n){ cout<<"Case "<<c++<<":"<<endl; set >s; while(

2017-10-15 22:47:47 244

原创 Nubulsa Expo. 全局最小割

#include //点标从0-n-1, 开始时先init 复杂度n^3//对于边(u,v,flow)://g[u][v]+=flow;//g[v][u]+=flow;typedef long long ll;const int N = 305;const ll inf = 1e18;ll g[N][N], w[N];int a[N], v[N], na[N];void add

2017-10-15 22:43:23 234

原创 hdu 3657 game 最小割

#include#include#includeusing namespace std;typedef long long ll ;#define captype intconst int MAXN = 40010; //点的总数const int MAXM = 400010; //边的总数const int INF = 1<<30;struct EDG{ i

2017-10-15 22:42:18 208

原创 Its rainning man!

/** * CTU Open 2016 * Problem Solution: It's Raining * * Case analysis. Main (but not the only) approach is to play * colors one by one. * @author Josef Cibulka */#include #include #inclu

2017-10-15 22:41:34 347

原创 Invertible tree 线段树 + dfs 序

#include #include #include #include #include using namespace std;int const SIZE = 100100;typedef long long weight_t;struct edge_t{ int to; int next;}Edge[SIZE<<1];int Vertex[SIZE];

2017-10-15 22:41:03 225

原创 tree standings 树 && dp

#include using namespace std ;#define MAXN 200#define MOD 1000000007typedef enum{ NO_STANDS = 0, SAFE_STANDS = 1, NOT_SAFE_STANDS = 2} state_t;int counts[MAXN][MAXN + 1][3]

2017-10-15 22:40:00 192

原创 南阳理工oj 746 整数划分(四) 区间dp

http://acm.nyist.net/JudgeOnline/problem.php?pid=746区间dp#include using namespace std ;typedef long long ll ;char read[40] ;int re[40] ;ll val[40][40] ;ll dp[40][40] ;int main(){

2017-10-15 22:37:45 233

原创 hdu 5943 二分图匹配

注意,并不是区间上存在超过2个素数就不成立当n > s 时 , 该条件不成立比如数据  125 1               2361 2事实上, 当n > s 时, 我们将s + 1 到 n 不动 , 此时只要判断 从n + 1 到 s + n 是否能成立即转换为输入系数为 s  n 是否成立s = 0 是特判成立会快一些其余即二分图可解决#incl

2017-10-12 23:08:34 192

原创 hdu 5934 强连通 && 判断覆盖图的最少点

bomb  a 能触发 b 则加一条a 到b 的边。用强连通缩点处理DAG中每个点的最小代价。覆盖图:所有出度为0的点必须要被覆盖,所有出度不为0的点均可由其他点覆盖。所以 : 只要所有出度为0的点, 就可以实现图的覆盖。#include #define mod 1000000007using namespace std ;typedef long long l

2017-10-12 09:31:39 301

原创 hdu 3820 最小割

#include#include#includeusing namespace std;typedef long long ll ;#define captype intconst int MAXN = 40010; //点的总数const int MAXM = 400010; //边的总数const int INF = 1<<30;struct EDG{ i

2017-10-11 23:08:21 278

原创 hdu 1569 最小割

给条件加边流量为inf,最小割求解#include#include#includeusing namespace std;typedef long long ll ;#define captype intconst int MAXN = 40010; //点的总数const int MAXM = 400010; //边的总数const int INF = 1<<30

2017-10-11 22:42:58 295

原创 方格取数 hdu 1565 最小割

选取的格子不相邻,即可以在相邻的格子间连一条流量为inf的边,不能被割去#include#include#include#includeusing namespace std;#define maxn 444#define maxm 33333#define INF 0x3f3f3f3fint head[maxn],cur[maxn],d[maxn],st[maxm],

2017-10-10 11:18:20 239

原创 Highest Tower

矩形转图论#include using namespace std;typedef long long ll ;const ll maxn = 250050 ;map ma ;int main(){ ll n , s , t , vertice , edge , max_vertice; ll ans = 0 ; //while( ~

2017-10-09 16:05:51 305

原创 Craters 计算几何

面积最大的三角形一定在定点的凸包上,然后枚举顶点注意longlong#include using namespace std ;#define maxn 200010typedef long long ll ;struct point{ ll x , y ;};point p[maxn] , stackn[maxn] ;ll n , k , top , le

2017-10-08 22:33:24 253

原创 new collections

交互题无话可说......#include using namespace std ;set s ;double magic[7]={10.0,100.0,999.96,6325.61,9517.19,9950.67,9995.01};void solve () { string c ; for ( int i = 1 ; i <= 10000 ; ++

2017-10-08 22:29:36 211

原创 generator

Ep 素数概率  , Ek 合数概率 , p 素数期望, k 合数期望 ( 平均)E = Ep * p + Ep * Ek * ( p + k )  + Ep * Ek * Ek * (p + 2 * k ) + Ep * Ek * Ek * Ek * ( p + 3 * k ) + .......    =    Ep * p *  ∑  (Ek ^ x) + Ep * k *

2017-10-08 22:18:00 205

原创 dinner party dp 暴力

dp用bitset处理读取时注意判断#include using namespace std ;typedef long long ll ; /*bitset bitvec2(0xffff); // bits 0 ... 15 are set to 1; 16 ... 31 are 0 cout << "bitvec2: " << bitvec2 << end

2017-10-07 22:02:51 334

原创 Construction sets 二分+背包

XVII Open Cup named after E.V. Pankratiev. XXI Ural Championship二分      用bitset处理背包#include using namespace std ;typedef long long ll ;int n , down , up ;int m[10000] , c[10000] ;bits

2017-10-07 22:01:35 1113

原创 card sorting

对纸牌正反排序暴力  , 状压#include using namespace std;int nu[200] , co[200] , best[200];int term[4] ;bool judge(int i , int j , int zhuangya){ if(co[i] == co[j]){ if((zhuangya>>co[i]) &

2017-10-07 21:56:20 623

原创 XVII Open Cup named after E.V. Pankratiev. Grand Prix of SPb D cutting potatoes

一堆数,最多能分n次,求分后最大值除以最小值的 最小值  #include #include #include #include #include #include using namespace std ;map ma ;int save[200] ;struct node{ int x , y ; double value ; bool oper

2017-10-06 22:40:37 412

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除