自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 快速筛法求素数

普通的线性筛法:#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>#define MAX 1000 // 范围using namespace std;int a[MAX],cnt;bool ispr[MAX];void prime(){...

2018-11-09 22:24:09 1101 1

原创 畅通工程续 HDU - 1874 (最短路)

 某省自从实行了很多年的畅通工程计划后,终于修建了很多路。不过路多了也不好,每次要从一个城镇到另一个城镇时,都有许多种道路方案可以选择,而某些方案要比另一些方案行走的距离要短很多。这让行人很困扰。 现在,已知起点和终点,请你计算出要从起点到终点,最短需要行走多少距离。Input本题目包含多组数据,请处理到文件结束。 每组数据第一行包含两个正整数N和M(0<N<200,0...

2018-08-17 20:44:00 142

原创 Til the Cows Come Home POJ - 2387 (最短路 dijkstra算法+ floyd算法)

Bessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get b...

2018-08-17 09:56:28 132

原创 Friend-Graph HDU - 6152 (暴力出奇迹)

It is well known that small groups are not conducive of the development of a team. Therefore, there shouldn’t be any small groups in a good team. In a team with n members,if there are three or more m...

2018-08-16 18:50:57 203

原创 P1012 拼数(字符串)

题目描述设有 nn 个正整数 (n≤20)(n≤20) ,将它们联接成一排,组成一个最大的多位整数。例如: n=3n=3 时, 33 个整数 1313 , 312312 , 343343 联接成的最大整数为: 3433121334331213又如: n=4n=4 时, 44 个整数 77 , 1313 , 44 , 246246 联接成的最大整数为: 74246137424613输...

2018-08-15 18:59:08 867

原创 Wireless Network POJ - 2236 (并查集)

An earthquake takes place in Southeast Asia. The ACM (Asia Cooperated Medical team) have set up a wireless network with the lap computers, but an unexpected aftershock attacked, all computers in the n...

2018-08-15 15:06:34 150

原创 A water problem HDU - 5832 (大位数取模)

Two planets named Haha and Xixi in the universe and they were created with the universe beginning. There is 7373 days in Xixi a year and 137137 days in Haha a year. Now you know the days NN after Bi...

2018-08-14 19:14:58 205

原创 Everything Has Changed HDU 6354 (数学)

Problem DescriptionEdward is a worker for Aluminum Cyclic Machinery. His work is operating mechanical arms to cut out designed models. Here is a brief introduction of his work.Assume the operating ...

2018-08-13 14:34:23 204

原创 盐水的故事 HDU 1408 (模拟 数学)

Problem Description挂盐水的时候,如果滴起来有规律,先是滴一滴,停一下;然后滴二滴,停一下;再滴三滴,停一下...,现在有一个问题:这瓶盐水一共有VUL毫升,每一滴是D毫升,每一滴的速度是一秒(假设最后一滴不到D毫升,则花费的时间也算一秒),停一下的时间也是一秒这瓶水什么时候能挂完呢?  Input输入数据包含多个测试实例,每个实例占一行,由VUL和D组成,其...

2018-08-13 14:30:40 157

转载 计算机三级网络技术 = =

 计算机三级网络技术考过指南 原文链接:计算机三级网络技术考过指南题库下载链接:计算机三级网络技术无纸化考试模拟软件(2018.3)目录: 三级网络技术考过指南前言(必读)1.基础准备1.1 题库1.2 二进制转换...

2018-08-13 11:25:24 38280 8

原创 Pinball HDU - 6373 (高中物理,我佛)

There is a slope on the 2D plane. The lowest point of the slope is at the origin. There is a small ball falling down above the slope. Your task is to find how many times the ball has been bounced on t...

2018-08-12 20:05:42 258

原创 The Suspects POJ - 1611(并查集)

Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. To minimize transmission to others, the best strategy is to s...

2018-08-10 20:20:57 102

原创 Ubiquitous Religions POJ - 2524(并查集)

There are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out how many different religions students in your university beli...

2018-08-10 19:07:04 103

原创 食物链 POJ - 1182(并查集)

动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物,用上述两种说法,一句接一句地说出K句话,...

2018-08-10 16:38:21 148

原创 Is It A Tree? POJ - 1308(并查集)

A tree is a well-known data structure that is either empty (null, void, nothing) or is a set of one or more nodes connected by directed edges between nodes satisfying the following properties. There...

2018-08-09 20:09:02 112

原创 小希的迷宫 HDU 1272(并查集)

小希的迷宫 HDU 1272Problem Description 上次Gardon的迷宫城堡小希玩了很久(见Problem B),现在她也想设计一个迷宫让Gardon来走。但是她设计迷宫的思路不一样,首先她认为所有的通道都应该是双向连通的,就是说如果有一个通道连通了房间A和B,那么既可以通过它从房间A走到房间B,也可以通过它从房间B走到房间A,为了提高难度,小希希望任意两个房间有且仅有一条...

2018-08-09 15:44:37 194

转载 并查集

原文地址   :http://blog.csdn.net/niushuai666/article/details/6662911作者:飘过的小牛并查集是我暑假从高手那里学到的一招,觉得真是太精妙的设计了。以前我无法解决的一类问题竟然可以用如此简单高效的方法搞定。不分享出来真是对不起pa...

2018-08-09 10:26:40 1545 3

原创 P1049 装箱问题 dp or dfs

题目描述有一个箱子容量为 VVV (正整数, 0≤V≤200000 \le V \le 200000≤V≤20000 ),同时有 nnn 个物品( 0<n≤300<n \le 300<n≤30 ,每个物品有一个体积(正整数)。要求 nnn 个物品中,任取若干个装入箱内,使箱子的剩余空间为最小。输入输出格式输入格式:111 个整数,表示箱子容量111 个整数,表示有...

2018-08-08 19:04:41 346

转载 01背包模板、完全背包 and 多重背包(模板)

01背包模板:/*01背包问题01背包问题的特点是,">每种物品仅有一件,可以选择放或不放。01背包问题描述:有N件物品和一个容量为V的背包。第i件物品的重量是c[i],价值是w[i]。求解将哪些物品装入背包可使这些物品的重量总和不超过背包容量,且价值总和最大。*/#include <stdio.h>#define N 1050017int max(int...

2018-08-08 09:40:28 1357 1

原创 免费馅饼 HDU - 1176

都说天上不会掉馅饼,但有一天gameboy正走在回家的小径上,忽然天上掉下大把大把的馅饼。说来gameboy的人品实在是太好了,这馅饼别处都不掉,就掉落在他身旁的10米范围内。馅饼如果掉在了地上当然就不能吃了,所以gameboy马上卸下身上的背包去接。但由于小径两侧都不能站人,所以他只能在小径上接。由于gameboy平时老呆在房间里玩游戏,虽然在游戏中是个身手敏捷的高手,但在现实中运动神经特别迟钝...

2018-08-07 18:52:37 109

原创 Tickets HDU - 1260

Jesus, what a great movie! Thousands of people are rushing to the cinema. However, this is really a tuff time for Joe who sells the film tickets. He is wandering when could he go back home as early as...

2018-08-07 18:49:14 84

原创 Common Subsequence POJ - 1458

A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = < x1, x2, ..., xm > another sequence Z = < z1, z2, ..., zk > is a ...

2018-08-07 18:45:25 138

原创 LIS

 Super Jumping! Jumping! Jumping! 题目链接:HDU - 1087 Nowadays, a kind of chess game called “Super Jumping! Jumping! Jumping!” is very popular in HDU. Maybe you are a good boy, and know little about...

2018-08-07 18:40:02 643

原创 Proud Merchants hdu3466 (动态规划)

Proud MerchantsProblem DescriptionRecently, iSea went to an ancient country. For such a long time, it was the most wealthy and powerful kingdom in the world. As a result, the people in this countr...

2018-08-06 18:38:37 263

原创 BFS练习

 UVA 439 Knight moveA friend of you is doing research on the Traveling Knight Problem (TKP) where you are to find the shortest closed tour of knight moves that visits each square of a given set of...

2018-08-03 18:23:32 218

原创 DFS练习

1 POJ 1979 Red and BlackDescriptionThere is a rectangular room, covered with square tiles. Each tile is colored either red or black. A man is standing on a black tile. From a tile, he can move...

2018-08-01 15:04:46 363

原创 递归+记忆化搜索

边界条件与递归方程是递归函数的两个要素。1)阶乘函数Int fac(int n){If (n==0) return 1;Else return n*fac(n-1);}这里,第一句的if是边界条件,第二句是递归方程。0的阶乘为1,n的阶乘为(n-1)的阶乘再乘n。2)汉诺塔问题Void move(int n,int a,int b,int c){If (...

2018-07-31 10:10:51 173

原创 DFS

概念DFS(Depth-First-Search)深度优先搜索算法。DFS一般用递归来实现,改变当层状态不断深入,直到找到答案或者已经可以知道这样下去无法得到答案,再返回到上一个状态(恢复该层状态)继续递归。保证每一个点(每一种可能性)都遍历过,但是并不能保证答案是最优解(如最小值,最短路等,这些一般用BFS实现)。 如图,在这棵树上做dfs为 1 2 4 5 3 6 7 ...

2018-07-29 16:30:47 254

原创 贪心算法

贪心算法(又称贪婪算法)是指,在对求解问题,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的是在某种意义上的局部最优解。贪心算法不是对所有问题都能得到整体最优解,关键是贪心策略的选择,选择的贪心策略必须具备无后效性,即某个状态以前的过程不会影响以后的状态,只与当前状态有关。  例题1:P1181 数列分段Section I题目描述对于给定的一个长...

2018-07-29 14:59:11 499

空空如也

空空如也

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

TA关注的人

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