第9期活动帖子:【CSDN竞赛第9期】赢CSDN专属周边和副总裁亲笔签名实体书!-CSDN社区

1、小艺读书


书是人类进步的阶梯。
小艺每周因为工作的原因会选择性的每天多读几页或者少读几页。
小艺想知道一本n页的书她会在周几读完。

输入描述:

第一行输入n(1<=n<=1000);
第二行输入7个整数,分别表示周一~周日的读书页数p(0<=p<=1000)。(不考虑7个整数都为0的情况)

输出描述:

输出答案。(1-7)

输入样例:

100
15 20 20 15 10 30 45

输出样例:

6
class Solution:def __init__(self) -> None:passdef solution(self, n, pages):result = None# TODO: 请在此编写代码page=sum(pages)book=n%pagefor i in range(7):book-=pages[i]if(book<=0):result=i+1breakreturn resultif __name__ == "__main__":n = int(input().strip())pages = [int(item) for item in input().strip().split()]sol = Solution()result = sol.solution(n, pages)print(result)

代码执行总结 运行次数: 162 运行时间: 15ms 占用内存: 9.207k

2、鬼画符门之宗门大比


给定整数序列A。
求在整数序列A中连续权值最大的子序列的权值。

输入描述:

第一行输入整数n.(1<=n<=1000)
第二行输入n整数a。(-1000<=a<=1000)

输出描述:

输出子序列最大权值。

示例:

示例1
输入

5
-1 2 3 -2 4

输出

7

示例2
输入

7
1 -4 6 7 -10 8 0

输出

11

提示
样例1:子序列最大权值为:2+3+(-2)+4=7
样例2:子序列最大权值为:6+7=13

class Solution:def __init__(self) -> None:passdef solution(self, n, arr):result = None# TODO: 请在此编写代码num=[]m=0for i in arr:m+=iif m<=0:m=0else:num.append(m)result=max(num)return resultif __name__ == "__main__":n = int(input().strip())arr = [int(item) for item in input().strip().split()]sol = Solution()result = sol.solution(n, arr)print(result)

代码执行总结 运行次数: 54 运行时间: 15ms 占用内存: 9.215k

3、硬币划分


有1分,2分,5分,10分四种硬币,每种硬币数量无限,给定n分钱(n<100000),有多少中组合可以组成n分钱?

输入描述:

输入整数n.(1<=n<=100000)

输出描述:

输出组合数,答案对1e9+7取模。

输入样例:

13

输出样例:

16
class Solution:def __init__(self) -> None:passdef solution(self, n):result = None# TODO: 请在此编写代码coins=[1,2,5,10]arr=[0]*1000001arr[0]=1for i in coins:for j in range(i,n+1):arr[j]=(arr[j]+arr[j-i])%(1e9+7)result=int(arr[n])return resultif __name__ == "__main__":n = int(input().strip())sol = Solution()result = sol.solution(n)print(result)

代码执行总结 运行次数: 216 运行时间: 49ms 占用内存: 9.262k

4、饿龙咆哮-逃离城堡


小艺酱误入龙族结界,被恶龙带回城堡,小艺酱决定逃离城堡,逃离龙族结界。
总路程为c, 小艺酱的速度是vp,饿龙速度为vd。饿龙会在t小时后发现小艺酱出逃。
小艺酱担心自己跑不出去,准备了好多珍宝。 每当饿龙追上自己的时候小艺酱就会丢下一个珍宝,饿龙捡到珍宝会返回自
己的城堡进行研究,研究f小时后,再出城堡追赶小艺。
小艺想知道自己至少需要丢多少珍宝才能让自己安全逃出结界。
输入描述:

输入整数vp,vd,t,f,c。(1<=vp,cd<=100,1<=t,f<=10,1<=c<=1000)

输出描述:

输出答案。

输入样例:

1
2
1
1
10

输出样例:

2

Escape
time limit per test: 2 seconds
memory limit per test: 256 megabytes
inputstandard input
outputstandard output

The princess is going to escape the dragon’s cave, and she needs to plan it carefully.
The princess runs at vpv_pvp​ miles per hour, and the dragon flies at vdv_dvd​ miles per hour. The dragon will discover the escape after ttt hours and will chase the princess immediately. Looks like there’s no chance to success, but the princess noticed that the dragon is very greedy and not too smart. To delay him, the princess decides to borrow a couple of bijous from his treasury. Once the dragon overtakes the princess, she will drop one bijou to distract him. In this case he will stop, pick up the item, return to the cave and spend fff hours to straighten the things out in the treasury. Only after this will he resume the chase again from the very beginning.
The princess is going to run on the straight. The distance between the cave and the king’s castle she’s aiming for is c miles. How many bijous will she need to take from the treasury to be able to reach the castle? If the dragon overtakes the princess at exactly the same moment she has reached the castle, we assume that she reached the castle before the dragon reached her, and doesn’t need an extra bijou to hold him off.

Input
The input data contains integers vp,vd,t,fv_p, v_d, t, fvp​, vd​, t, f and ccc, one per line (1≤vp,vd≤100,1≤t,f≤10,1≤c≤1000)(1 ≤ v_p, v_d ≤ 100, 1 ≤ t, f ≤ 10, 1 ≤ c ≤ 1000)(1 ≤ vp​, vd​ ≤ 100,1 ≤ t, f ≤ 10,1 ≤ c ≤ 1000).
Output
Output the minimal number of bijous required for the escape to succeed.

Examples
input
1
2
1
1
10

output
2

input
1
2
1
1
8

output
1

Note
In the first case one hour after the escape the dragon will discover it, and the princess will be 1 mile away from the cave. In two hours the dragon will overtake the princess 2 miles away from the cave, and she will need to drop the first bijou. Return to the cave and fixing the treasury will take the dragon two more hours; meanwhile the princess will be 4 miles away from the cave. Next time the dragon will overtake the princess 8 miles away from the cave, and she will need the second bijou, but after this she will reach the castle without any further trouble.
The second case is similar to the first one, but the second time the dragon overtakes the princess when she has reached the castle, and she won’t need the second bijou.

class Solution:def __init__(self) -> None:passdef solution(self, vp, vd, t, f, c):result = None# TODO: 请在此编写代码result=0sp=vp*twhile sp<c:if vd-vp<=0:return 0rt=sp/(vd-vp)sp+=vp*rtif sp<c:result+=1sp+=vp*(rt+f)return resultif __name__ == "__main__":vp = int(input().strip())vd = int(input().strip())t = int(input().strip())f = int(input().strip())c = int(input().strip())sol = Solution()result = sol.solution(vp, vd, t, f, c)print(result)

代码执行总结 运行次数: 108 运行时间: 14ms 占用内存: 9.262k

【CSDN竞赛第9期】 Python 题解相关推荐

  1. csdn程序竞赛第六期-python题解

    CSDN编程竞赛报名地址:https://edu.csdn.net/contest/detail/16 前言/背景 第一次参加这个竞赛,记录一下比赛题解,希望和你一起进步 解题思路 1.严查枪火 X国 ...

  2. CSDN竞赛第54期编程题解(个人解答)

    1.题目名称:陶陶摘苹果 陶陶家的院子里有一棵苹果树,每到秋天树上就会结出 10 个苹果.苹果成熟的时候,陶陶就会跑去摘苹果.陶陶有个 30厘米高的板凳,当她不能直接用手摘到苹果的时候,就会踩到板凳上 ...

  3. CSDN竞赛—第六期题解与感想

    CSDN编程竞赛报名地址:https://edu.csdn.net/contest/detail/16 CSDN竞赛-第六期题解与感想 前言/背景 参赛经历 解题思路 经验心得 资料分享 第六期题解 ...

  4. CSDN竞赛第32期题解

    CSDN竞赛第32期题解 1.题目名称:传奇霸业 传奇霸业,是兄弟就来干. 小春(HP == a)遇到了一只黄金哥布林(HP == x). 小春每次能对哥布林造成b点伤害,哥布 林每次能对小春造成y点 ...

  5. CSDN竞赛—第五期题解与感想

    CSDN竞赛-第五期题解与感想 一.题解 1. 寻因找祖 解题思路 AC代码 题外话 2. 通货膨胀-x国货币 解题思路 AC代码 3. 莫名其妙的键盘 解题思路 参考代码 4. 三而竭 解题思路 A ...

  6. 剪拼子字符串——常规、另类两种算法解CSDN竞赛第八期第一小题

    [点击此处跳转笔记正文] Python 官网:https://www.python.org/ Free:大咖免费"圣经"教程< python 完全自学教程>,不仅仅是基 ...

  7. 【CSDN竞赛第四期】编程赛后总结与分享

    [CSDN竞赛第四期]编程赛后感 先放成绩:77.5分,除去作弊的人排名**[15/951]** 谈不上满意,毕竟还有可以进步的空间,希望下次更好.下面进入正题: 1.小玉家的电费 [题目描述] 夏天 ...

  8. 【CSDN竞赛第四期】赢荣誉证书和CSDN周边等精美礼品

    一.竞赛奖励 注:获奖用户需要在CSDN发布一篇竞赛相关博客才可获得奖品,内容创作方向需围绕竞赛相关,如本次竞赛的bug,对CSDN竞赛的建议,以往参加各类编程竞赛的比赛经历等等 二.竞赛流程 报名: ...

  9. 【CSDN竞赛第10期】赢定制周边和《软件研发效能权威指南》实体书!

    一.竞赛奖励 本场竞赛由「电子工业出版社 & CSDN」联合主办,可点击此处前往查看<软件研发效能权威指南> [实物奖励] 1. 排名第 1 - 3 名 的参赛者可获得电子工业出版 ...

最新文章

  1. 在Gridview控件中根据Field Name来取得对应列索引
  2. 【粉丝福利】今天不谈技术,只送福利!
  3. 微信小程序-学习笔记6-组件
  4. DIV+CSS列表式布局(同意图片的应用)
  5. 记录一次IDEA开发JavaWeb项目时JS中文乱码排错方法
  6. Keras一些基本概念
  7. 吴恩达机器学习作业 1线性回归
  8. java开发中的各种中间件技术
  9. python联合vrep_python控制vrep代码实例
  10. 【算法:leetcode】双指针:142. 环形链表 II 633. 平方数之和
  11. 巴旦木即将成为农业的下一个“风口”河南巴旦木生态农业:值得期待
  12. no suitable conversion function from “std::reverse_iterator<double *>“ to “double *“ exists
  13. Flutter 入门笔记 三
  14. 开源的Android视频播放器
  15. GUCCI、LV等奢侈品巨头如何布局元宇宙的,其他品牌应该跟上吗?
  16. 通常所说微型计算机的奔3,求江西省2011年计算机等级一级考试试题
  17. Java-Quartz定时器
  18. Linux != Windows
  19. 撤销院士称号!两名原院士,被当作反面典型通报
  20. 网工上午经典考题汇总---必记

热门文章

  1. python script爬虫_人肉python脚本爬虫
  2. masquerade词根词缀_GRE填空题-同向逻辑和词汇记忆法
  3. 何为内核青年?内在觉醒、内在驱动更有助于人生的成功
  4. 超详细 某代刷网站js逆向
  5. [绍棠] iOS开发经验总结
  6. 实战 Vue 之实现添加和删除常用应用功能
  7. ICASSP2022论文阅读记录3 - TalkingFlow
  8. gt爵士变形步骤_代码广播简介:编码时您可以收听的24/7爵士节奏
  9. 基于Keras的单变量单时间步长LSTM电力负荷预测(一)
  10. vue获取当前时间并时时刷新