- 博客(24)
- 收藏
- 关注
原创 hdu 1195 双向bfs
http://acm.hdu.edu.cn/showproblem.php?pid=1195 这代码好长,不过好多重复的内容。#include <iostream>#include <queue>#include <cstring>using namespace std;struct node{ int x, step;};int vis[10000];node q1[10
2015-06-19 18:07:57 271
原创 hdu 1686 Oulipo
http://acm.hdu.edu.cn/showproblem.php?pid=1686 简单kmp#include <cstdio>#include <cstring>using namespace std;int Next[10005];char c[1000005];char t[10005];int main(){ int num; scanf("%d",
2015-06-09 22:04:57 222
原创 hdu 1358 period
http://acm.hdu.edu.cn/showproblem.php?pid=1358 求某个前缀含几个循环 用kmp的next数组#include <cstdio>#include <cstring>using namespace std;int Next[1000005];char c[1000005];int main(){ int len; int cnt
2015-06-09 21:17:39 350
原创 hdu 1671 字典树
http://acm.hdu.edu.cn/showproblem.php?pid=1671 简单的字典树 注意每次要释放内存 不然会MLE#include <iostream>#include <cstring>#include <string>#include <algorithm>using namespace std;struct node{ int sign;
2015-06-08 23:48:25 279
原创 hdu 1251 字典树
http://acm.hdu.edu.cn/showproblem.php?pid=1251 MLE了无数次…最后换了种方法#include <iostream>#include <cstring>#include <cstdio>using namespace std;struct node{ int num; int next[26]; void ini()
2015-06-08 14:55:29 265
原创 hdu 2899 二分
http://acm.hdu.edu.cn/showproblem.php?pid=2899在[0,100]上F’x单调增 所以求F’(x0)=0 将x0代入F(x) 即为答案#include <cstdio>#include <cmath>#include <iostream>using namespace std;const double res=1e-6;double ans(d
2015-06-04 21:41:12 300
原创 hdu 1394 线段树求逆序数
http://acm.hdu.edu.cn/showproblem.php?pid=1394#include <cstdio>using namespace std;const int maxx=5100;int sum[maxx<<2];#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1void pushup(int rt){ s
2015-06-01 08:40:00 216
原创 hdu 1754 I hate it
http://acm.hdu.edu.cn/showproblem.php?pid=1754#include <cstdio>using namespace std;const int maxx=200000;int sum[maxx<<2];#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1int MAX(int a, int b){
2015-05-31 23:53:23 217
原创 hdu 1166 敌兵布阵
http://acm.hdu.edu.cn/showproblem.php?pid=1166 线段树模板题#include <cstdio>using namespace std;#define lson l,m,rt<<1#define rson m+1,r,rt<<1|1const int maxx=55555;int sum[maxx<<2];void PushUp(int rt
2015-05-31 22:50:38 247
原创 dp hdu 1160 FatMouse's Speed
http://acm.hdu.edu.cn/showproblem.php?pid=1160#include <iostream>#include <algorithm>#include <cstdio>using namespace std;struct mice{ int w,s,num,p;};bool cmp(mice a, mice b){ if(a.w==
2015-05-29 21:00:14 226
原创 dp hdu 1003 maxsum
http://acm.hdu.edu.cn/showproblem.php?pid=1003#include <iostream>using namespace std;int a[100001];int main(){ int t,n,b,e,rb,maxx,sum,k; cin>>t; k=1; while(t--) { cin>>
2015-05-29 20:59:12 207
原创 dfs hdu 1016
http://acm.hdu.edu.cn/showproblem.php?pid=1016#include <cstdio>#include <cstring>using namespace std;int prime[40]={0};int n,count;int ans[21];int vis[21];void dfs(int x){ if(count==n&&!pri
2015-05-27 10:39:04 227
原创 二分图匹配 hdu 1150
http://acm.hdu.edu.cn/showproblem.php?pid=1150#include <iostream>#include <cstring>using namespace std;const int maxx=102;int gra[maxx][maxx];int cx[maxx];int cy[maxx];int sy[maxx];int m,n,ans,k
2015-05-27 01:29:44 230
原创 数论 hdu 1060 n^n最高位
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=2§ionid=1&problemid=11 对一个数num可写为 num=10^n * a, 即科学计数法,使a的整数部分即为num的最高位数字num^num=10^n + a 这里的n与上面的n不等两边取对数: num*lg(num) = n + lg(a);因为
2015-05-27 01:02:07 328
原创 dp hdu 1159 最大公共子序列
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=3§ionid=2&problemid=2 dp[i][j]=max(dp[i-1][j],dp[i][j-1]) s1[i]!=s2[j] dp[i][j]=dp[i-1][j-1]+1 s1[i]==s2[j]#include<stdio.h> #includ
2015-05-27 00:58:38 221
原创 dp hdu 1176
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=3§ionid=2&problemid=8 自底向上 状态转移方程为:dp[i][j]=max(dp[i+1][j-1],dp[i+1][j],dp[i+1][j-1])+pie[i][j]#include<stdio.h> #include<string.h.>
2015-05-27 00:52:24 202
原创 二分图匹配 hdu 2063
http://acm.hdu.edu.cn/showproblem.php?pid=2063#include <iostream>#include <cstring>using namespace std;const int maxx=502;int gra[maxx][maxx];int sx[maxx];int sy[maxx]; //记录是否被访问过int cx[maxx];int
2015-05-27 00:50:39 265
原创 二分图匹配 hdu 1045
http://acm.hdu.edu.cn/showproblem.php?pid=1045#include <iostream>#include <cstring>using namespace std;const int maxx=102;int cx[maxx];int cy[maxx];int sx[maxx];int sy[maxx];char gra[maxx][maxx];
2015-05-27 00:46:20 245
原创 大数相减
#include <iostream>#include <string>#include <mem.h>using namespace std;int main(){ string s1,s2; cin>>s1>>s2; int a[1000]; int b[1000]; memset(a,0,sizeof(a)); memset(b,0,si
2015-05-07 22:35:27 308
原创 大数相加
A + B Problem IITime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 251504 Accepted Submission(s): 48449Problem Description I have a very simpl
2015-04-28 08:38:28 205
原创 HDU 2136 Largest prime factor
Problem Description Everybody knows any number can be combined by the prime number. Now, your task is telling me what position of the largest prime factor. The position of prime 2 is 1, prime 3 is 2
2015-04-27 08:13:29 228
原创 [leetcode] Number of Islands
Given a 2d grid map of ‘1’s (land) and ‘0’s (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume
2015-04-22 16:14:28 218
原创 HDU 1106 排序
Problem Description 输入一行数字,如果我们把这行数字中的‘5’都看成空格,那么就得到一行用空格分割的若干非负整数(可能有些整数以‘0’开头,这些头部的‘0’应该被忽略掉,除非这个整数就是由若干个‘0’组成的,这时这个整数就是0)。你的任务是:对这些分割得到的整数,依从小到大的顺序排序输出。Input 输入包含多组测试用例,每组输入数据只有一行数字(数字之间没有空格),这行数字
2015-04-14 12:31:00 217
原创 HDU 2550百步穿杨
Problem Description 时维九月,序属三秋,辽军大举进攻MCA山,战场上两军正交锋.辽军统帅是名噪一时的耶律-James,而MCA方则是派出了传统武将中草药123.双方经过协商,约定在十一月八日正午十分进行射箭对攻战.中草药123早早就开始准备,但是他是武将而不是铁匠,造弓箭的活就交给聪明能干的你了,现在告诉你每种弓箭规格,即箭身的长度,以及每种规格弓箭所需要的数目,要求你把需要的
2015-04-14 12:24:58 406
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人