caioj1522: [NOIP提高组2005]过河

状态压缩的经典题。

按照一般做法,DP一维时间O(n),显然跑不过。考虑到石子较少,实际上有很长一段是一定可以跳到的,设两个石头分别在i点和j点,跳跃的路程为S到T。那么从i点可以跳到i+S到i+T。从j-T到j-S可以跳到J。显然当i和j相隔非常非常远时,从i到i+T中必然可以经过若干次跳跃,然后跳到j-T到j的任意一段。

然后状压,可以发现距离大于90(假设s和t不同,s(9)和t(10)的最小公倍数)一定可以到达,这样我们把石头之间的距离%90节省时间。

然后特判一下s==t的情况,就可以AC。但有一个问题,我将mod变成100,不特判s==t的情况,这样会WA,这个我无法理解。

 

数据:10000
7 7 100
1111 1118 1114 1117 3010 7508 1119 1105 899 1112 9667 3238 1108 5178 4627 2116 2089 9184 1115 8887 3565 3560 3559 3562 2410 3564 3571 565 3561 3566 3573 7432 9485 4484 7258 4555 8812 1291 3567 3221 5252 5253 5244 797 5251 7885 5245 9340 5255 6537 7737 5243 9316 5246 6694 6773 5247 6031 5256 5249 5484 5482 7513 5485 5479 5481 5480 5489 381 2572 9255 7624 5821 8606 7829 5488 442 5490 5492 8098 483 482 481 478 469 474 4054 472 471 4407 479 7006 475 470 3147 6933 9097 7781 473 2221
应该输出10但是改了输出13.

 

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int se[110],a[1100000],f[1100000];
int main()
{int L,s,t,n;scanf("%d%d%d%d",&L,&s,&t,&n);for(int i=1;i<=n;i++)scanf("%d",&se[i]);sort(se+1,se+n+1);if(s==t){int ans=0;for(int i=1;i<=n;i++)if(se[i]%s==0)ans++;printf("%d\n",ans);return 0;}for(int i=1;i<=n;i++)se[i]=se[i-1]+(se[i]-se[i-1])%90;L=(L-se[n])%90+se[n];for(int i=1;i<=n;i++)a[se[i]]=1;memset(f,63,sizeof(f));f[0]=0;for(int i=s;i<=L+t;i++)for(int j=s;j<=t;j++)if(i>=j)f[i]=min(f[i],f[i-j]+a[i]);int ans=999999999;for(int i=L;i<L+t;i++)ans=min(ans,f[i]);printf("%d\n",ans);return 0;
}

 

转载于:https://www.cnblogs.com/AKCqhzdy/p/7616899.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/391230.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Dev控件使用CheckedListBoxControl获取items.count为0 的解决方法

CheckedListBoxControl&#xff0c;我使用DataSource属性&#xff0c;给其绑定了一个List对象。界面显示都挺正常的&#xff0c;当若干个项的复选框被选中的后&#xff0c;它的checkedListBoxControl1.CheckedItems也是正常的。 唯独的问题是在代码中得到的checkedListBoxContr…

如何启动软件YouTube频道

Hi, I’m Beau and I run the freeCodeCamp.org YouTube channel. 嗨&#xff0c;我是Beau&#xff0c;我运行了freeCodeCamp.org YouTube频道 。 For the first few years of our channel’s life, we had less than 100,000 subscribers. When we published new videos, we …

【powerdesign】从mysql数据库导出到powerdesign,生成数据字典

使用版本powerdesign16.5&#xff0c;mysql 5.5&#xff0c;windows 64 步骤&#xff1a; 1.下载mysql驱动【注意 32和64的驱动都下载下来&#xff0c;具体原因查看第三步 依旧会报错处】 下载地址&#xff1a;https://dev.mysql.com/downloads/connector/odbc/5.3.html 请下…

php amazon-s3_推荐亚马逊电影-一种协作方法

php amazon-s3Item-based collaborative and User-based collaborative approach for recommendation system with simple coding.推荐系统的基于项目的协作和基于用户的协作方法&#xff0c;编码简单。 推荐系统概述 (Overview of Recommendation System) There are many met…

[高精度乘法]BZOJ 1754 [Usaco2005 qua]Bull Math

模板题目&#xff0c;练练手~ #include <iostream> #include <algorithm> #include <cstring> #include <cstdio> using namespace std;int s1[2333]; int s2[2333]; int Out[2333]; string one,two;void Debug(){for(int i0;i<one.length();i){pri…

python:使用Djangorestframework编写post和get接口

1、安装django pip install django 2、新建一个django工程 python manage.py startproject cainiao_monitor_api 3、新建一个app python manage.py startapp monitor 4、安装DRF pip install djangorestframework 5、编写视图函数 views.py from rest_framework.views import A…

Kubernetes 入门(3)集群安装

1. kubeadm简介 kubeadm 是 Kubernetes 官方提供的一个 CLI 工具&#xff0c;可以很方便的搭建一套符合官方最佳实践的最小化可用集群。当我们使用 kubeadm 搭建集群时&#xff0c;集群可以通过 K8S 的一致性测试&#xff0c;并且 kubeadm 还支持其他的集群生命周期功能&#…

Angular Material 攻略 04 Icon

Icon 网页系统中的Icon虽然说很简单&#xff0c;但是其中的学问还是有很多的&#xff0c;我们常用的Icon库有FontAwesome、Iconfont等&#xff0c;我们选择了Angular Material这个组件库&#xff0c;就介绍Material Icons吧。 对Icon感兴趣的同学可以看一下这里 Material Desig…

【9303】平面分割

Time Limit: 10 second Memory Limit: 2 MB 问题描述 同一平面内有n&#xff08;n≤500&#xff09;条直线&#xff0c;已知其中p&#xff08;p≥2&#xff09;条直线相交与同一点&#xff0c;则这n条直线最多能将平面分割成多少个不同的区域&#xff1f; Input 两个整数n&am…

简述yolo1-yolo3_使用YOLO框架进行对象检测的综合指南-第一部分

简述yolo1-yolo3重点 (Top highlight)目录&#xff1a; (Table Of Contents:) Introduction 介绍 Why YOLO? 为什么选择YOLO&#xff1f; How does it work? 它是如何工作的&#xff1f; Intersection over Union (IoU) 联合路口(IoU) Non-max suppression 非最大抑制 Networ…

django:资源网站汇总

Django REST framework官网 http://www.sinodocs.cn/ django中文网 https://www.django.cn/ 转载于:https://www.cnblogs.com/gcgc/p/11542068.html

Kubernetes 入门(4)集群配置

1. 集群配置 报错&#xff1a; message: ‘runtime network not ready: NetworkReadyfalse reason:NetworkPluginNotReady message:docker: network plugin is not ready: cni config uninitialized’ 原因&#xff1a;cni未被初始化&#xff08;CNI 是 Container Network In…

【例9.8】合唱队形

【例9.8】合唱队形 链接&#xff1a;http://ybt.ssoier.cn:8088/problem_show.php?pid1264 时间限制: 1000 ms 内存限制: 65536 KB【题目描述】 N位同学站成一排&#xff0c;音乐老师要请其中的(N-K)位同学出列&#xff0c;使得剩下的K位同学排成合唱队形。 合唱队形是…

scrum流程 规划 冲刺_Scrum –困难的部分2:更快地冲刺

scrum流程 规划 冲刺In the first part, I presented my favorite list of Scrums hard parts and how to work around them. In the second part, I offer you a colorful bouquet of workarounds as well. Have fun!在第一部分中 &#xff0c;我介绍了我最喜欢的Scrum困难部分…

JAVA基础知识|lambda与stream

lambda与stream是java8中比较重要两个新特性&#xff0c;lambda表达式采用一种简洁的语法定义代码块&#xff0c;允许我们将行为传递到函数中。之前我们想将行为传递到函数中&#xff0c;仅有的选择是使用匿名内部类&#xff0c;现在我们可以使用lambda表达式替代匿名内部类。在…

数据库:存储过程_数据科学过程:摘要

数据库:存储过程Once you begin studying data science, you will hear something called ‘data science process’. This expression refers to a five stage process that usually data scientists perform when working on a project. In this post I will walk through ea…

901

901 转载于:https://www.cnblogs.com/Forever77/p/11542129.html

leetcode 137. 只出现一次的数字 II(位运算)

给你一个整数数组 nums &#xff0c;除某个元素仅出现 一次 外&#xff0c;其余每个元素都恰出现 三次 。请你找出并返回那个只出现了一次的元素。 示例 1&#xff1a; 输入&#xff1a;nums [2,2,3,2] 输出&#xff1a;3 示例 2&#xff1a; 输入&#xff1a;nums [0,1,0,…

【p081】ISBN号码

Time Limit: 1 second Memory Limit: 50 MB 【问题描述】 每一本正式出版的图书都有一个ISBN号码与之对应&#xff0c;ISBN码包括9位数字、1位识别码和3位分隔符&#xff0c;其规定格式如“x-xxx-xxxxx-x”&#xff0c;其中符号“-”是分隔符&#xff08;键盘上的减号&#xff…

gitlab bash_如何编写Bash一线式以克隆和管理GitHub和GitLab存储库

gitlab bashFew things are more satisfying to me than one elegant line of Bash that automates hours of tedious work. 没有什么比让Bash自动完成数小时繁琐工作的Bash优雅系列令我满意的了。 As part of some recent explorations into automatically re-creating my la…