自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(77)
  • 资源 (1)
  • 收藏
  • 关注

原创 HDU 1880 魔咒词典

字符串哈希水题 #include #include #include #include #include using namespace std; #define debug cout<<"***"<<endl; map m1,m2; const int maxn=105000; char spell[maxn][100]; char magic[maxn][100]; int f

2015-07-11 16:19:57 955

原创 HDU 1576 A/B

由题得A=Bx,且A=9973*y+n 所以可得Bx-9973*y=n 由扩展欧几里得算法可求得x 又因为(A/B)%9973的结果就是x%9973,解之。 #include #include #include #include using namespace std; long long extend_gcd(long long a,long long b,long long &

2015-07-11 10:45:49 653

原创 HDU 4009 Transfer water

最小树形图模板题 #include #include #include #include #include using namespace std; int n,X,Y,Z; struct node { int x,y,z; }vill[1200]; const int MAXM=40010; const int MAXN=1010; const int INF=0x3f3f3f3f

2015-05-31 12:37:00 500

原创 HDU 4004 The Frog's Games

二分最小的能力值,然后对该值进行判断,看是否能至多m步跳到河对岸 #include #include #include #include #include using namespace std; int a[500055]; int L,n,m; int maxn; int check(int v){ int num=0; int i=0; int pos=1; while(

2015-05-28 19:53:12 570

原创 HDU 4006 The kth great number

动态求第k大的数,只需维护一个长度为k的优先队列 #include #include #include #include #include #include using namespace std; int main(){ int n,k; while(scanf("%d%d",&n,&k)!=EOF){ priority_queue, greater >

2015-05-27 08:22:13 416

原创 poj 2001 Shortest Prefixes

题目要求的是每个单词的直接前缀是什么,什么是直接前缀呢,直接前缀就是以该直接前缀的子树有且只有该单词  所以,我们只需要沿着以该单词构建的字典树走,输出所有cnt>1的结点和最后一个cnt==1的结点既得答案 #include #include #include #include using namespace std; char ch[1500][30]; int le=1; str

2015-05-10 16:18:14 494

原创 Codeforces 466C Number of Ways

题意很容易理解,要求的是如何将一段序列划分为3段,每一段的和都为sum/3,求所有的划分数 自己没想出来,看的标准题解(捂脸) 1.如果序列的和不能整除3,那么划分数肯定为0 2.如果序列的和能整除3,那么我们只需要找到所有使得前i个点之和为sum/3的这些点,然后看在这些点之后有多少个点能使从第一个点开始到他们这些点为止使得序列之和为sum*2/3,最后将这些点的个数累加起来得到答案。

2015-05-08 20:30:12 478

原创 HDU 3549 Flow Problem

最大流模板题 #include #include #include #include #include using namespace std; int n,m; int g[20][20]; int pre[20]; int visit[20]; int Augment(){ memset(pre,0,sizeof(pre)); memset(visit,0,sizeof(vis

2015-05-08 20:12:27 403

原创 HDU 5210 Delete

比赛的时候,yy的贪心策略错了,wa了6次(哭瞎) 正确的贪心策略是,先把重复的数字的个数跟删除操作的次数比较,如果小于等于重复数字的个数,则在集合内的个数就是答案,如果大于重复数字的个数,那就在集合中删数,最后输出集合的剩余个数 #include #include #include #include #include #include #include #include #i

2015-04-30 08:24:34 478

原创 HDU 1709 The Balance

稍微变了一点的母函数,因为砝码可以摆在左右两边,所以我们可以令母函数为(x^-i+1+x^i),当x的指数为负时,表示砝码与重物放在一边,其他砝码则在另一边 #include #include #include #include using namespace std; int n; int sum; int a1[12000],a2[12000]; int a[105]; int an

2015-04-29 23:09:12 449

原创 HDU 1085 Holding Bin-Laden Captive!

还是母函数 数组又忘记每次初始化,调了一个小时……╮(╯▽╰)╭╮(╯▽╰)╭╮(╯▽╰)╭ #include #include #include #include using namespace std; int a,b,c; int a1[10050]; int a2[10050]; void solve(){ memset(a2,0,sizeof(a2)); me

2015-04-28 14:53:45 401

原创 HDU 1398 Square Coins

还是母函数模板题 #include #include #include #include using namespace std; int a1[350]; int a2[350]; int solve(int n){ for(int i=0;i<=n;i++){ a1[i]=1; a2[i]=0; } for(int i=2;i<=n;i++){ for(int j=

2015-04-28 12:55:13 493

原创 HDU 1028 Ignatius and the Princess III

今天早上先把学堂在线里组合数学的母函数撸了一遍,然后直接来刷母函数的题目了。 这道题是求整数无序划分的个数,母函数典型的应用 做法:套整数划分母函数的模板 #include #include #include #include using namespace std; int a1[200]; int a2[200]; int solve(int n){ for(int i=0;i

2015-04-28 09:38:28 416

原创 Codeforces 400A Inna and Choose Options

简单模拟,判断某一列是不是全由‘X’构成 #include #include #include #include using namespace std; int ans1[100],ans; char ch[20]; int main(){ int t; scanf("%d",&t); while(t--){ scanf("%s",ch); int len=strlen(

2015-04-26 18:44:46 442

原创 Codeforces 476B Dreamoon and WiFi

说好的用dp呢!!!结果dfs一遍就过了 题意大致是,给你两个字符串,一个字符串只由‘+’和‘-’构成,另外一个字符由‘+’、‘-’和‘?’构成,‘?’可能是‘+’也可能是‘-’,题目要求的就是如何将问号改变使得该字符串与另一个字符串‘+’和‘-’数目完全一样的概率 两个字符串的长度都不超过10,所以O(2^N)的复杂度是可以承受的 #include #include #include

2015-04-24 13:31:54 565

原创 Codeforces 489C Given Length and Sum of Digits

贪心可解,对于最大值来说只要从开始一直找最大的,对于最小值来说,先在第一位放1,然后倒推最后一位开始放9,最后如果到第一位还有剩余的话就直接加到第一位上去。 #include #include #include #include #include using namespace std; char con[]={'0','1','2','3','4','5','6','7','8','

2015-04-22 22:32:39 670

原创 Codeforces 515C Drazil and Factorial

第一次尝试做Codeforces div2的C题,果然凭现在的智商还是想不出来的 官方题解讲的很清楚:http://codeforces.com/blog/entry/16468

2015-04-22 16:45:13 499

原创 Codeforces 313B Ilya and Queries

水dp~~~~ #include #include #include using namespace std; char ch[100050]; int dp[100050]; int main(){ int n,m; while(scanf("%s",ch)!=EOF){ memset(dp,0,sizeof(dp)); n=strlen(ch); dp[0]=0;

2015-04-20 19:12:00 536

原创 HDU 1176 免费馅饼

一道简单dp,用数组dp[ i ][ j ]表示在第i秒时,坐标为j的点上最多获得的馅饼数 直接上代码 #include #include #include #include #include using namespace std; int a[100050][15]; int dp[100050][15]; int main(){ int n; while(scanf("%d

2015-03-29 18:46:12 398

原创 poj 3928 Ping pong

大白书上的原题,用树状数组统计出i两边有多少比num[i]小的,由乘法原理和加法原理就可得; 终于看懂树状数组了~~ #include #include #include #include using namespace std; const int maxn=100050; int num[maxn]; long long a[maxn]; long long c[maxn]; lo

2015-03-18 21:51:42 507

原创 poj 3070 Fibonacci

第一道矩阵快速幂的题目,其实跟整数的快速幂没什么区别嘛,无非就是多一个矩阵的乘法操作和构造一个单位矩阵      其实这种类型的题目难点在于如何构造出矩阵出来,但这道题直接告诉你了公式,那就是裸的模板题了      #include #include #include #include #include using namespace std; const int MOD = 100

2015-02-20 15:21:21 431

原创 HDU 2817 A sequence of numbers

水题,题目要求的就是等比数列或是等差数列的第k项 等差数列就直接套通项公式嘛 等比数列的话由于k可能非常大,所以要用快速幂 #include #include #include #include using namespace std; #define MOD 200907 int solve(int fac,int num){ if(fac==0) retu

2015-02-19 22:43:10 522

原创 HDU 1301 Jungle Roads

裸的最小生成树 #include #include #include #include using namespace std; const int INF=0x3f3f3f3f; const int maxn=30; bool vis[maxn]; int lowc[maxn]; int cost[maxn][maxn]; int n; int prim(){ int ans=0;

2015-02-17 22:21:58 414

原创 HDU 1010 Tempter of the Bone

一道搜索题,需要加奇偶剪枝,需要注意的地方是题目要求在T时刻时刚好到达D位置。 顺带吐槽一下,调试的时候遇到各种奇葩错误,例如去掉提示信息后,答案居然不一样,尼玛,这么会有这种错误啊啊啊啊。 G++提交WA,C++提交AC又是什么鬼啊 #include #include #include #include using namespace std; int N,M,T; int sx,

2015-02-17 20:13:56 420

原创 Codeforces Round #291 (Div. 2) Han Solo and Lazer Gun

虽然好像是一道水题,但写这篇文章的意义在于——我第一次做出了CF的B题啊啊啊啊。 做法就是计算所有卫兵的点与枪的点之间的斜率(其实用叉积做更好一些),然后对斜率排个序,再扫一遍就可以了嘛。 #include #include #include #include #include using namespace std; #define eps 0.000000001 #define

2015-02-17 16:24:06 622

原创 HDU 5167 Fibonacci

题目要求的是判断一个数是不是Fibonacci数的乘积,前面想当然以为只要是两个数的乘积就行,但显然两个以上的Fibnoacci数的乘积也是可以的。 找到错误之后就用DFS搜索一遍就OK了,但姿势不好的话,就会超时。 姿势不好的dfs int dfs(long long n){ if(n==1) return 1; for(int i=0;i<cnt;i++)

2015-02-02 10:23:11 627

原创 poj 3087 Shuffle'm Up

简单模拟就能搞的题~~~#include #include #include #include using namespace std; char ch1[1000],ch2[1000],ch3[2000]; int main(){ int t; scanf("%d",&t); int cnt=0; string str1,str2,str3; while(++cnt<=t){

2015-02-01 22:42:30 499

原创 poj 3984 迷宫问题

最基本的bfs,只是要输出最短路径经过哪些点,网上的高端代码看不懂,只好弱弱的用STL上了。 #include #include #include #include #include #include #include #include using namespace std; int Map[5][5]; int Ans[5][5]; bool flag[5][5]; int

2014-12-24 21:23:27 650

原创 poj 3278 Catch That Cow

水水的bfs #include #include #include #include #include using namespace std; #define INF 100000 int N,K; int ans[100005]; int flag[100005]; queue q; void bfs(){ while(!q.empty()){ int pos=q.fron

2014-12-19 22:15:55 645

原创 poj 2251 Dungeon Master

三维上的bfs,水题一发。 #include #include #include #include #include using namespace std; #define INF 1000000 queue q1,q2,q3;; char Map[35][35][35]; int ans[35][35][35]; int flag1[35][35][35]; int L,R,C;

2014-12-17 21:56:47 601

原创 poj 1321 棋盘问题

直接暴搜就ok,按行dfs,那么行就不会冲突,然后再对列进行标记,判断同一列是否冲突。 做完这道题之后有几个感受:首先总体思路很浅显直白,但在细节实现上,有好多盲点没注意到,还是看discuss上的数据才找到bug,郁闷~~~ #include #include #include #include using namespace std; char Map[10][10]; int f

2014-12-16 18:21:07 508

原创 HDU1159 && POJ1458:Common Subsequence(LCS)

必须得啃DP了,就从最简单的DP入门题开始了。

2014-12-12 22:46:06 586

原创 POJ 3461 Oulipo

#include #include #include #include #include using namespace std; const int maxn=100005; char w[maxn]; char t[maxn*10]; int next[maxn]; void get_next() { int i=0; next[0]=-1; int j=-1

2014-11-20 14:48:57 594

原创 POJ 3264 Balanced Lineup

线段树模板题,求qujia

2014-11-19 17:26:52 539

原创 HDU 4716 A Computer Graphics Problem

#include #include #include using namespace std; int main(){ int t; scanf("%d",&t); int pos=1; while(t--){ printf("Case #%d:\n",pos++); int num; scanf("%d",&num); printf("*------------*\

2014-11-19 12:39:31 610

原创 HDU 4727 The Number Off of FFF

水题,注意当所有人都

2014-11-18 22:59:09 534

原创 HDU 4772 Zhuge Liang's Password

#include #include #include #include #include using namespace std; int a[305][305],b[305][305]; int N; void solve(){ memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); for(int i=1;i for(int

2014-11-17 22:51:24 672

原创 HDU 3342 Legal or Not

拓扑排序,直接pan

2014-11-12 23:04:35 639

原创 HDU 2647 Reward(反向拓扑)

这题给的内存忒小了,不能用邻接矩阵存,只能用邻接表

2014-11-12 22:22:30 679

原创 Uva 10305 Ordering Tasks(拓扑排序)

/* Kahn 算法 复杂度:O(E+V) L← Empty list that will contain the sorted elements S ← Set of all nodes with no incoming edges while S is non-empty do remove a node n from S insert n into L for eac

2014-11-08 15:50:50 620

统计学习方法

统计学习方法,好书.pdf

2016-01-14

空空如也

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

TA关注的人

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