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
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",
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
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;
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()
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
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|1 void pushup(int rt) { s
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|1 int MAX(int a, int b) {
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|1 const int maxx=55555; int sum[maxx<<2]; void PushUp(int rt
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==
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>>
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
二分图匹配 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
数论 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);因为
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
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.>
二分图匹配 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
二分图匹配 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];
大数相减 #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
大数相加 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