自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

MY Blog

我最讨厌中途放弃的人

  • 博客(16)
  • 收藏
  • 关注

原创 poj 3273 二分

n个数分为最多m段 如何分能让最大段最小二分答案然后判断ACcode:#include #include #include #include using namespace std;int n,m,l,r,mid;int a[100005];int fun(int x){ int t=1,tmp=0; for(int i=1;i<=n;++i){

2017-03-31 20:41:09 233

原创 poj 1416 dfs

提议:给你2个数n,m m最大为6位数把m数看成字符串分割成任意个数,这些数加起来不大于n如果存在唯一的最接近n的解输出分割方案如果不唯一输出rejected如果不存在输出errorACcode:#include #include #include #include using namespace std;int n,m,len;int ans,time

2017-03-31 19:20:45 362

原创 poj 2531 DFS

题意:给你n个点以及他们之间交互的值,问把这些点分为2堆,得到的最大值是多少分析:暴力dfs即可ACcode:#include #include #include #include using namespace std;int a[25][25];int vis[25];int ans,n;void dfs(int x,int num){ vis[x]

2017-03-31 16:27:50 355

原创 poj 3414 bfs+记录路劲

水题///复制粘贴时候忘记改数字wa了2次  真是蠢ACcode:#include #include #include #include using namespace std;struct N{ queueans; int x,y; int st;};int vis[105][105];int main(){ int x,y,c;

2017-03-31 15:22:52 297

原创 poj 3087 水模拟

ACcode:#include #include #include #include using namespace std;char a[105],b[105],s[105+105],c[105+105];int main(){ int loop,n,cnt=1; scanf("%d",&loop); while(loop--){ scan

2017-03-31 14:19:30 398

原创 poj 3009 冰壶 dfs

题意:给你一个n*m的图,进行冰壶游戏。每次操作可以向上下左右四个方向投掷冰壶当往一个方向投掷冰壶时,只有碰到墙壁才会停止(并击碎该墙壁)如果没有墙壁,则冰壶回飞出地图,视为失败给定起点和终点问是否能在10次操作内到达终点如果能输出最小步数否则输出-1ACcode:///注意飞出图外的情况#include #include #include #include u

2017-03-30 20:09:02 640

原创 poj 3083 Children of the Candy Corn bfs

题意:给你一个n*m的迷宫从起点到终点靠右行走、靠左行走、和最短行走的步数是多少分析:最短就直接bfs就好了,对于靠右(左)行走的情况下我们可以想象每次选择的方向跟当前人面向方向有关,一开始我们假定人是面向前的然后开始模拟注意对于迷宫中的每一个点都可以经过4次(即从上下左右4个方向经过)那么用vis【】【】【4】来判定是否走过这步ACcode:///写的又臭又长 差点崩溃

2017-03-29 19:26:16 631

原创 poj 2488 A Knight's Journey

题意:给你一个n*m的棋盘,问是否存在一条供马走的路能访问棋盘上所有的点如果存在输出字典序最小的路反之输出impossible分析:直接dfs就行,注意dx【】dy【】数组 因为要字典序输出路径ACcode:#include #include #include #include #include #include #include using namespace

2017-03-29 15:53:15 322

原创 poj 2442 Sequence 堆

题意:给你m*n的矩阵问每行取一个数构成一个含m个数的序列,求序列和最小的前n个序列的和分析:对于m等于一的情况那么显然降序输出第一行的数就是答案对于m等于二的情况:先读入第一行数据到一个堆中(堆的大小一直保持在n)对于第二行的数据:先把堆中的数取出来记为a【】;开始读入第二行的数据记为b【】;如果读入的是b【0】那么把a【k】+b【0】压入堆中如果读入的是b【j】

2017-03-29 14:17:37 303

原创 poj 2002 has

题意:给1000个点,问其中任取4个点构成正方形的取法有多少种分析:我们知道通过一个正方形2个点可以确定另外两个点,那么我们只需要枚举这2个点就可以了。先把所有点hash然后枚举看是否存在这样的点已知: (x1,y1)  (x2,y2)则: x3=x1+(y1-y2)   y3= y1-(x1-x2) x4=x2+(y1-y2)   y4= y2-(x1-x2)或: x

2017-03-29 12:20:02 372

原创 poj 1840 Eqs hash

题意:对于公式: a*x1^3+b*x2^3+c*x3^3+d*x4^3+e*x5^3=0其中(a,b,c,d,e,x1,x2,x3,x4,x5)都在区间【-50,50】中给出a,b,c,d,e求满足等式的情况分析:等式===》-(a*x1^3+b*x2^3)=c*x3^3+d*x4^3+e*x5^3又因为每个值范围在【-50,50】之间那么对于没一个数范围为【-1250000

2017-03-28 19:12:23 381

原创 poj 2151 Check the difficulty of problems 概率dp

题意:  给出M个题目由N个队来做时每个队作对每道题的概率问满足下列条件的概率为1:每个队最少完成一道题目2:最少有一个队完成的题目为T分析:这是一个概率问题记A:每个队最少完成一道题目 B:最少有一个队完成的题目为T  p【i】【j】为第i队作对第j题的概率那么ans=f(A)-f(A*~B)我们可以用dp【i】【j】【k】表示第i个队前j题能够作对k题的概率

2017-03-28 17:46:01 320

原创 poj 2993 Emag eht htiw Em Pleh 模拟

参考 2996思路模拟code:#include #include #include #include #include #include using namespace std;#define maxn 105char str[maxn];char m[9][9];int has[128];int main(){ has['K']=1;has['Q']=2;

2017-03-27 18:36:15 300

原创 poj 2996 Help Me with the Game 模拟

模拟 要细心啊code:#include #include #include #include #include #include using namespace std;#define maxn 105char str[maxn];char m[9][9];int has[128];struct N{ int t; int x,y; char

2017-03-27 17:09:33 393

原创 poj 2632 模拟

按题意模拟就行///写了2个小时内心是崩溃的 还好1Acode:#include #include #include #include #include using namespace std;#define maxn 100005int mapp[105][105];struct P{ int x,y; int to;///0--N 1--E 2--S 3

2017-03-27 14:56:59 285

原创 hdu 4991 dp+数状数组

题意:给定长为n的序列求长度为m的递增子序列有多少个,答案mod123456789容易想到dp【i】【j】表示长度为i的序列中递增子序列长度为j的个数有多少。那么dp【i】【j】=sum(dp【k】【j-1】)(1显然朴素算法复杂度是n^2对于sum(dp【k】【j】)区间求和我们可以用二维数状数组维护那么nlogn就可以接受这题对于给出的数据n可能数字很大可以离散化到1~

2017-03-24 13:47:57 304

空空如也

空空如也

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

TA关注的人

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