第一题: HDU 5804 链接

0 ~ 商品总和之间的任意价格都可以取到 每次判断记录是否大于总和即可

代码:

#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#define sf scanf
#define pf printf
using namespace std;
typedef long long LL;int main(){int T,n,m;LL temp,sum;sf("%d",&T);while( T-- ){sum = 0;sf("%d %d",&n,&m);for(int i = 0;i < n;++i){sf("%I64d",&temp);sum += temp;}for(int i = 0;i < m;++i){sf("%I64d",&temp);if(temp > sum){pf("1");}else pf("0");}pf("\n");}return 0;
}

第二题: HDU 5805 链接

记录前缀和后缀最大值f,g 枚举所有去掉点 求左端点 的 前缀最大值 、右端点后缀最大值,左右端点距离 的MAX 求和即可

long long 没注意 被hack了
然后hack我的人 我已经关注你了!

代码:

#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#define sf scanf
#define pf printf
#define fabs(n) ((n) > 0 ? n : -(n))
using namespace std;
typedef long long LL;
const int maxn = 100000 + 5;
int A[maxn];
int pre_max[maxn];
int tail_max[maxn];
int main(){int T;sf("%d",&T);while( T-- ){int n;sf("%d",&n);for(int i = 0;i < n;++i){sf("%d",&A[i]);}pre_max[0] = 0;for(int i = 1;i < n;++i){pre_max[i] = max(pre_max[i - 1],fabs(A[i - 1] - A[i]));}tail_max[n - 1] = 0;for(int i = n - 2;i >= 0;--i){tail_max[i] = max(tail_max[i + 1],fabs(A[i + 1] - A[i]));}LL ans = 0;for(int i = 1;i < n - 1;++i){ans += max(pre_max[i - 1],max( tail_max[i + 1] ,fabs(A[i - 1] - A[i + 1])) );}ans += tail_max[1] + pre_max[n - 2];pf("%I64d\n",ans);}return 0;
}

第三题: HDU 5806 链接

和题解的比起来我的有些复杂
枚举区间坐端点 之后二分查找合法的最左右端点p
∑(n - p + 1)就是答案了

代码:

#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#define sf scanf
#define pf printf
using namespace std;
const int maxn = 200000 + 5;
int sum[maxn];
typedef long long LL;
int main(){
//    freopen("read.txt","r",stdin);int T;sf("%d",&T);int n,k,m;while( T-- ){sf("%d%d%d",&n,&m,&k);for(int i = 1;i <= n;++i){sf("%d",&sum[0]);if(sum[0] >= m){sum[i] = 1;}else sum[i] = 0;}sum[0] = 0;for(int i = 1;i <= n;++i){sum[i] = sum[i - 1] + sum[i];}
//        for(int i = 1;i <= n;++i) pf("%d\n",sum[i]);LL ans = 0;for(int i = 1;i <= n;++i){
//            pf("aa");int p = lower_bound(sum + 1,sum + n + 1,sum[i - 1] + k) - sum;ans += n - p + 1;}pf("%I64d\n",ans);}return 0;
}

第四题:HDU 5807 链接

简单的DAG图 初始化将两个城市不能通信的状态值 设为0
dp[i][j][k] = ∑dp[a][b][c]
加了一个状态p表示此时是第几个人移动到 0表示3人都移动完成 加快的算法速度

代码:

#include <cstdio>
#include <iostream>
#include <queue>
#include <vector>
#include <cstring>
#define sf scanf
#define pf printf
using namespace std;
int fabs(int n){return n > 0 ? n : -n;
}
typedef long long LL;
const int maxn = 51;
const LL mod = 998244353;
LL dp[maxn][maxn][maxn][4];
int kk[maxn];
vector<int> Adj[maxn];
LL get_next_point(int a,int b,int c,int lable){LL &ans = dp[a][b][c][lable];if(ans != -1) return ans;ans = 0;if(lable == 0){ans = 1;ans += get_next_point(a,b,c,1);ans %= mod;
//        pf("%d %d %d %lld\n",a,b,c,ans);return ans;}if(lable == 1){for(int i = 0;i < Adj[a].size();++i){ans += get_next_point(Adj[a][i],b,c,2);ans %= mod;}}if(lable == 2){for(int i = 0;i < Adj[b].size();++i){ans += get_next_point(a,Adj[b][i],c,3);ans %= mod;}}if(lable == 3){for(int i = 0;i < Adj[c].size();++i){ans += get_next_point(a,b,Adj[c][i],0);ans %= mod;}}return ans;
}void init(){for(int i = 0;i < maxn;++i){Adj[i].clear();}
}int main(){
//    freopen("read.txt","r",stdin);int T;int n,m,k,q;sf("%d",&T);while( T-- ){init();sf("%d%d%d%d",&n,&m,&k,&q);for(int i = 1;i <= n;++i){sf("%d",&kk[i]);}for(int i = 0;i < m;++i){int u,v;sf("%d%d",&u,&v);Adj[u].push_back(v);}memset(dp,-1,sizeof(dp));for(int i = 1;i <= n;++i){for(int j = 1;j <= n;++j){if(fabs( kk[i] - kk[j] ) > k){
//                    pf("%d %d\n",i,j);for(int p = 1;p <= n;++p){dp[i][j][p][0] =  dp[i][p][j][0] = dp[p][i][j][0] = 0;}}}}for(int i = 0;i < q;++i){int a,b,c;sf("%d%d%d",&a,&b,&c);printf("%lld\n",get_next_point(a,b,c,0));}}return 0;
}

BestCoder Round #86 HDU 5804,HDU 5805,HDU 5806,HDU 5807相关推荐

  1. HDU 5804 BestCoder Round #86 Price List (水题)

    Price List 题目链接: 点我打开链接 Source BestCoder Round #86  题意:有一个人去 n 间商店购物,在每家商店购买最多一件物品,也可以什么都不买.给你每家商店的物 ...

  2. BestCoder Round #86 1002 HDU 5805 ——NanoApe Loves Sequence

    题意 给定一个数列,随机从该数列里删除一个数,求该数列的的相邻之间的绝对值的最大值的和. 思路 两个数列来分别维护i位前面的相邻的绝对值的最大以及i后面的最大,枚举每一个可能删除的数,然后分别从左右和 ...

  3. BestCoder Round #86 1003 HDU 5806——NanoApe Loves Sequence Ⅱ

    题意: 给定一个序列,问在这个序列里有多少区间第k的的数>=m 思路: 在比赛的时候是多想了,开始像区间第k大的问题,赛后想想实在是偏了. 正确的解法是枚举起点然后用尺取法维护一段区间,直到找到 ...

  4. hdu5804(BestCoder Round #86 A)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5804 解题思路:水题,计算给出的数值的和,然后在每次查询的时候比较数字与之前求出的和的大小,若大于,则 ...

  5. hdu 4956 Poor Hanamichi BestCoder Round #5(数学题)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4956 Poor Hanamichi Time Limit: 2000/1000 MS (Java/Ot ...

  6. HDU 5228 ZCC loves straight flush( BestCoder Round #41)

    题目链接:ZCC loves straight flush 题面: ZCC loves straight flush Time Limit: 2000/1000 MS (Java/Others)    ...

  7. HDU 5597 GTW likes function(规律+欧拉函数模板题)——BestCoder Round #66(div.1 div.2)

    GTW likes function Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Oth ...

  8. hdu4585 amp; BestCoder Round #1 项目管理(vector应用)

    主题链接:http://acm.hdu.edu.cn/showproblem.php?pid=4858 项目管理 Time Limit: 2000/1000 MS (Java/Others)    M ...

  9. hdu4932 Miaomiao#39;s Geometry (BestCoder Round #4 枚举)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4932 Miaomiao's Geometry Time Limit: 2000/1000 MS (Ja ...

最新文章

  1. python函数的参数类型,Python函数的主要参数类型
  2. Struts2文件上传
  3. CRecordset类
  4. java获取spring数据源_Spring动态注册多数据源的实现方法
  5. 计算机应用专业可以考教师资格证不,电大的大专学历可以考教师资格证吗?
  6. java商城管理系统_基于SSM框架的JAVA商场管理系统
  7. Nessus最新版8.15安装教程
  8. 在图像中剪切圆形图片
  9. 1362:家庭问题(family)(并查集)
  10. 微信小程序实现一行滑动显示很多文字--scroll-view
  11. 小小一方士 C# Async\Await
  12. 计算机的管理软件有哪些,电脑里有很多文件,很乱但是都有用,有什么管理软件值得推荐?...
  13. C select 函数
  14. OpenCV - C++ -图像处理 //使用
  15. acme.sh使用阿里云DNS申请Let’s Encrypt的https证书
  16. Linux rpm -ivm,Linux常见命令
  17. 三十行代码教你做个通用文字识别程序
  18. 软件性能测试重要性,软件性能测试的重要性及策略(2)
  19. 国产汽车级可编程线性霍尔传感器CHA611,可以替代Allegro的A1363系列产品,解决汽车级芯片缺货难题
  20. pandas读取xlsx

热门文章

  1. 按键精灵模拟键盘批量输入英文大小写
  2. 推荐几个免费好用的毕业论文(设计)文献查找网站包括外文文献(亲测有用)
  3. 20200305沈剑阿里云MVP分享笔记
  4. Mac系统升级Python版本(Python2.7升级到Python3.8.2)
  5. 图像互信息(MI)的计算(Python版本)
  6. primocache学生党常用场景设置
  7. 树莓派3b+,4b新手入门到手开箱第一次使用之十大步骤
  8. 你的春节放假通知邮件发送了吗?邮件自动回复设置
  9. 机器学习-华为mindspore入门-波士顿房价回归
  10. 个别化教育计划IEP模板