![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
HDOJ
PeterBishop0
一起进步!
展开
-
1050房间桌椅转移
#include<cstdio> #include<cstring> #include<algorithm> using namespace std;//这是区间最大重载数问题 int main() { int t, n, count[410], i, start, end, k; scanf("%d", &t); while (t--) { ...原创 2018-03-12 21:19:34 · 315 阅读 · 0 评论 -
2604 Queuing(递推+矩阵快速幂)
分析: 题目要求不含101 和111 的串 设f[n]为长度为n串符合条件的个数 则很明显在长度为(n-1)并且符合条件的串后面加上一个0一定符合 如果在长度为n-1的串后面加上一个1的话我们得考虑n-1的串结尾的元素 如果是00的话我们可以看做是长度为n-3的串加上100 如果是10的话我们可以看做长度为n-4的串加上1100 因此f[n]=f[n-1]+f[n-3]+f[n-4]...原创 2018-09-15 23:28:20 · 264 阅读 · 0 评论 -
1757 A Simple Math Problem(矩阵快速幂入门题)
矩阵快速幂看这里 题意:求下图公式的结果 这一题 还是个 递推关系式 的矩阵就非常的好推了 和之前的几乎一样 这里就不解释了 #include<cstdio> #include<cstring> using namespace std; const int N=10; int n,mod; int temp[N][N]; int res[N][N],a...原创 2018-09-13 21:40:07 · 287 阅读 · 0 评论 -
1260 Tickets(一维简单dp)
简单易懂,水题 #include<iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<cmath> #include<algorithm> using namespace std; int main() { ...原创 2018-12-04 15:01:38 · 296 阅读 · 0 评论 -
1069 Monkey and Banana (dp最长有序子序列)
/* *********************************************** Author :PeterBishop Created Time :Wed 06 Mar 2019 20:01:57 CST File Name :test.cpp Origin :H D O J 1069 ************************...原创 2018-12-04 15:15:58 · 304 阅读 · 0 评论 -
1213 并查集模板(计算集合数)
/* *********************************************** Author :PeterBishop Created Time :Sat 16 Feb 2019 21:23:18 CST File Name :t.cpp Origin :H D O J 1213 ***************************...原创 2019-02-16 21:35:36 · 410 阅读 · 0 评论 -
1029 小技巧(n+1)/2
利用好这个至少出现(n+1)/2很重要,O(nlgn)才能ac,真是服了这题目 /* *********************************************** Author :PeterBishop Created Time :Tue 05 Mar 2019 20:26:16 CST File Name :test.cpp Origin ...原创 2019-03-05 20:51:40 · 457 阅读 · 0 评论 -
1024 m段连续上升区间最大值
个人感觉dp的维度就是说的要去遍历的方向,动态打表毕竟,可以先通过最暴力的方法找到递推式子或者举例找出规律,自顶而下去思考才是正道 /* *********************************************** Author :PeterBishop Created Time :Mon 04 Mar 2019 18:29:12 CST File Name ...原创 2019-03-04 19:48:21 · 3988 阅读 · 0 评论 -
1087 最大上升子序列
看清题目哇!!可以任选就可以上升子序列了,还有就是dp还是不熟悉基本模板 自顶而下在意讲当前状态设为最后的状态,进行比较和取舍,空当接龙玩的好的估计dp都厉害 /* *********************************************** Author :PeterBishop Created Time :2019年03月15日 星期五 09时08分33...原创 2019-03-15 09:34:19 · 295 阅读 · 0 评论 -
1257 经典LIS
最长上身子序列的长度等于不下降子序列的个数 /* *********************************************** Author :PeterBishop Created Time :2019年03月18日 星期一 21时56分54秒 File Name :t.cpp ************************************...原创 2019-03-19 22:25:20 · 225 阅读 · 0 评论 -
1114 完全背包模板
还是要先去刷一刷背包九讲啊! /* *********************************************** Author :PeterBishop Created Time :2019年03月16日 星期六 11时14分58秒 File Name :t.cpp *******************************************...原创 2019-03-16 16:56:42 · 376 阅读 · 0 评论 -
1176 免费馅饼
dp思路很清楚,但是边界问题要弄清,还有就是遍历顺序要弄清楚 /* *********************************************** Author :PeterBishop Created Time :2019年03月18日 星期一 13时26分26秒 File Name :t.cpp ***************************...原创 2019-03-18 16:09:24 · 244 阅读 · 0 评论 -
1061 Rightmost Digit(快速幂取模)
快速幂取模看这里! #include<stdio.h> int power(long long a,int n) { long long ans=1; while(n>0) { if(n&1) { ans*=a; ans%=10; } ...原创 2018-09-11 14:42:15 · 200 阅读 · 0 评论 -
1043 Eight(八数码问题 康托展开 A*算法)
首先介绍一下A*算法: https://blog.csdn.net/qq_40061421/article/details/81915573 然后是康托展开: https://blog.csdn.net/qq_40061421/article/details/81915838 A*:f=g+h函数。g表示从起点到当前点的移动步数,h表示对当前点到目标点的最小移动步数的预测。除去起点和目标点...原创 2018-08-22 21:15:09 · 506 阅读 · 0 评论 -
1241 Oil Deposits(dfs经典)
#include<stdio.h> #include<string.h> char map[110][110]; int move[8][2]={1,0,-1,0,0,1,0,-1,1,1,-1,-1,1,-1,-1,1};//两个坐标一组 分为8组 int h,w; void dfs(int x,int y)//定义dfs函数,主函数找到了@,dfs启动,寻找主函数找到...原创 2018-07-26 22:53:40 · 272 阅读 · 0 评论 -
1045堡垒冲突问题
#include<iostream> #include<algorithm> #include<iomanip> using namespace std; char map[5][5]; int res; int n; bool judge(int x, int y) { if (map[x][y] != '.') return false; for (...原创 2018-03-12 21:18:54 · 367 阅读 · 0 评论 -
1051LIS木棍问题
#include<iostream> #include<algorithm> using namespace std; struct wood { int len; int wei; bool v ;//用来标记防止重复访问 }w[5001]; bool cmp(wood a, wood b) { if (a.len == b.len) return a.w...原创 2018-03-13 17:26:02 · 226 阅读 · 0 评论 -
2717抓羊BFS
#include <stdio.h>//也是BFS的模板题,三个搜索方向,分别判断,挺好想到的 #include <string.h> #include <queue> using namespace std; const int N = 1000000; int map[N + 10]; int n, k; struct node { int x, st...原创 2018-04-14 20:51:12 · 294 阅读 · 0 评论 -
1495可乐分配问题也可以BFS
#include<cstdio>//一开始找规律,虽然总感觉能找到但是很浪费时间其实,然后看到了BFS简直豁然开朗 #include<cstring> #include<algorithm> #include<queue> #define N 100+5 using namespace std; struct node{ int a,b,...原创 2018-04-15 15:16:53 · 322 阅读 · 0 评论 -
2612两人路径和最短
#include<cstdio> #include<iostream> #include<cstdlib> #include<cstring> #include<queue> using namespace std; struct node { int x, y, step; };//记录点的坐标以及到...原创 2018-04-16 17:04:30 · 279 阅读 · 0 评论 -
1241水dfs连接在一起的算一个
//这题经典dfs,不过告诉我一个道理,方向什么的列举好了,写数组循环容易各种智障犯错误,,,, #include <iostream> #include <stdio.h> using namespace std; char map[101][101]; int n, m, sum; void dfs(int i, int j) { //若该点不可行或越界,返...原创 2018-04-17 08:57:57 · 319 阅读 · 0 评论 -
1263 水果(自定义map)
#include<iostream> #include<string> #include<map> using namespace std; //map<string,map<string,int>>这种比较新奇,解决了三个变量的键值对应 struct MyStruct { map <string, int>MyStruc...原创 2018-07-11 10:49:40 · 345 阅读 · 0 评论 -
1027 Ignatius and the Princess II(next_permutation的应用)
#include<stdio.h> #include<algorithm> using namespace std; int a[10005]; int main(){ int n,k,m,i; while(~scanf("%d%d",&n,&k)){ m=1; for(i=0;i<=n+1;i++) a[i]=i+1; whil...原创 2018-07-12 09:22:59 · 228 阅读 · 0 评论 -
4277 USACO ORZ (set+dfs)
#include <iostream> #include <cstdio> #include <cstring> #include <set> #include<algorithm> using namespace std; set<pair<int,int> >s; int a[110],n,b[4],fla原创 2018-07-12 09:49:13 · 311 阅读 · 0 评论 -
1075 What Are You Talking About (字符串处理+map字典)
#include <map> #include <string.h> #include <iostream> #include<string> using namespace std; #include<stdio.h>//存字典+读取翻译(字符串操作的经典) int main() { char s1[20], s2[20], s[30...原创 2018-07-12 10:14:37 · 222 阅读 · 0 评论 -
1509 Windows Message Queue (priority_queue的自定义类型+重载比较函数)
#include<cstdio> #include<queue> using namespace std; struct node { int sign, vip, num;//顺序,优先值,变量值 char mbr[400]; //变量名开大点 bool friend operator < (node a, node b) {//重载一...原创 2018-07-12 10:36:19 · 322 阅读 · 0 评论 -
1074 状压dp好题
题解: 首先,dp思想: 假设dp[ _ , _ ,_ ,…… ,_ ,_ ,_ ]记录了:n门课,在一些完成了,一些未完成的状态下,当前已经花去的时间(time),以及,当前已经被扣掉的最少分数(rs); 例如:有3门课,那么dp[0,0,0]代表了三门课作业还未做完的状态,dp[0,1,1]代表第二门和第三门的作业已经做完,第一门课作业还没做完的状态; 那么,我们状态转移方程...转载 2019-03-13 16:42:04 · 301 阅读 · 0 评论