GDUT_排位赛题解报告_第3场_D. Race

ComfyUI 在线平台大比拼:哪个最适合你的AI绘画需求?(含详细对比表) 本文深入评测了五大主流ComfyUI在线平台,包括哩布AI、吐司Art、eSheep等,通过详细对比表展示它们在语言支持、免费额度、分辨率等核心功能上的差异。针对不同用户群体(如中文新手、团队协作)提供匹配策略,并分析云部署与扩展生态的进阶方案,帮助用户根据需求选择最适合的AI绘画工具。 阅读详情

Bessie is running a race of length K (1≤K≤109) meters. She starts running at a speed of 0 meters per second. In a given second, she can either increase her speed by 1 meter per second, keep it unchanged, or decrease it by 1 meter per second. For example, in the first second, she can increase her speed to 1 meter per second and run 1 meter, or keep it at 0 meters per second and run 0 meters. Bessie’s speed can never drop below zero.

Bessie will always run toward the finish line, and she wants to finish after an integer amount of seconds (ending either at or past the goal line at this integer point in time). Furthermore, she doesn’t want to be running too quickly at the finish line: at the instant in time when Bessie finishes running K meters, she wants the speed she has just been traveling to be no more than X (1≤X≤105) meters per second. Bessie wants to know how quickly she can finish the race for N (1≤N≤1000) different values of X.

Input
The first line will contain two integers K and N.

The next N lines each contain a single integer X.

Output
Output N lines, each containing a single integer for the minimum time Bessie needs to run K meters so that she finishes with a speed less than or equal to X.

Example
inputCopy
10 5
1
2
3
4
5
outputCopy
6
5
5
4
4
Note
When X=1, an optimal solution is:

Increase speed to 1 m/s, travel 1 meter Increase speed to 2 m/s, travel 2 meters, for a total of 3 meters Keep speed at 2 m/s, travel 5 meters total Keep speed at 2 m/s, travel 7 meters total Keep speed at 2 m/s, travel 9 meters total Decrease speed to 1 m/s, travel 10 meters total

When X=3, an optimal solution is:

Increase speed to 1 m/s, travel 1 meter Increase speed to 2 m/s, travel 3 meters total Increase speed to 3 m/s, travel 6 meters total Keep speed at 3 m/s, travel 9 meters total Keep speed at 3 m/s, travel 12 meters total

Note that the following is illegal when X=3:

Increase speed to 1 m/s, travel 1 meter Increase speed to 2 m/s, travel 3 meters total Increase speed to 3 m/s, travel 6 meters total Increase speed to 4 m/s, travel 10 meters total

This is because at the instant when Bessie has finished running 10 meters, her speed is 4 m/s.

这个题就是一个模拟:
就是在限制最终速度为x的情况下,要跑出的最长距离需要在比赛中途达到最快速度并马上放缓速度,而此时跑完固定距离所需要的时间也是最短的,根据这种思路开始模拟.

推式子的时候要小心不要推错,然后就是非常简单的代码实现,难在分类和数学上面。
然后就是完整代码:

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <climits>
#include <queue>
#include <stack>
#include <map>
//鬼畜头文件
using namespace std;
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
typedef unsigned long long ULL;
typedef long long LL;
//鬼畜define
LL k,n,x;
LL all[100010];
int main()
{
	all[0]=0;
	for(int time=1;time<100010;time++)
	{
		all[time]=all[time-1]+(LL)time;
	}
	scanf("%lld %lld",&k,&n);
	for(int time=0;time<n;time++)
	{
		scanf("%lld",&x);
		LL mid;
		for(mid=1;1;mid++)
		{
			if(mid>=x&&mid+all[mid-1]*2>all[x-1]+k)break;
			if(mid<x&&all[mid]>k)break;
		}
		mid--;
 
		LL need=k+all[x-1]-mid-all[mid-1]*2;
		if(all[mid]==k&&mid<=x)printf("%lld\n",mid);
		else if(all[mid]<k&&mid+1<=x)printf("%lld\n",mid+1);
		else if(need==0)printf("%lld\n",mid*2-x);
		else if(need<=mid)printf("%lld\n",mid*2-x+1);
		else printf("%lld\n",mid*2-x+2);
	}
	return 0;
}
Windows11上CUDA 12.3配PyTorch踩坑记:一条官网命令救了我的GPU加速 本文详细介绍了在Windows 11上配置CUDA 12.3与PyTorch的完整指南,包括环境准备、安装要点、兼容性解决方案和性能验证。通过官方推荐的conda命令和实用技巧,帮助开发者解决常见问题,实现高效的GPU加速,提升深度学习开发效率。 阅读详情

相关推荐

企业AI Agent的审计与合规

本文将带你从**“0基础理解企业AI Agent审计与合规”到核心概念梳理:用大白话+学术定义拆解什么是“企业AI Agent”、“可审计性(Auditability)”、“可解释性(Explainability,XAI)≠可审计性”、“合规性(Compliance)”、“黑盒拆解的三层维度”等硬核但必须掌握的概念;风险与合规背景:从**内部风险(数据泄露、误操作、模型偏差)和。

Java大师兄的博客 301

GDUT_排位赛题解报告_第2场_B. Snakes

题目: B. Snakes time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output According to legend, St. Patrick banished all of the snakes in Mooland over a tho...

DevourPower的博客 369

10分钟学会工程领域Hypermesh与Abaqus联立处理大量铆钉连接简化做法

铆钉连接是一种可靠且高强度的机械连接方式,广泛应用于多个领域。但是,工程结构上铆钉连接往往以较大的数量出现,若按照常规的一个个去选择生成,处理1个铆钉连接点需要1分钟来算,300个铆钉需要5个小时,耗费大量的时间成本。给出了一种高效处理铆钉连接的方法,提升效率50倍以上。

qq_34933927的博客 1615

GDUT_排位赛题解报告_第4场_E. Binary Tree

题目: In computer science, a binary tree is a rooted tree in which each node has at most two children. In this problem, let’s denote n as the number of nodes, l as the number of leaf nodes and h as the ...

DevourPower的博客 597

ZYNQ实战:PS端驱动DMA实现高效数据流转与验证

本文详细介绍了在ZYNQ平台上通过PS端驱动DMA实现高效数据流转的实战方法。从ZYNQ的PS与PL数据交互基础出发,深入解析DMA核心价值,包括硬件平台搭建、Vivado配置、PS端软件架构设计及性能优化技巧,帮助开发者提升数据传输效率与系统性能。

weixin_29192141的博客 436

PYNQ-Z2 开发板从镜像烧录到 Jupyter 交互全流程指南

本文详细介绍了PYNQ-Z2开发板从镜像烧录到Jupyter交互的全流程指南,包括硬件解析、镜像烧录技巧、设备启动与网络配置、Jupyter Notebook深度使用以及实战案例分享。通过具体步骤和实用技巧,帮助开发者快速上手PYNQ-Z2开发板,实现高效的FPGA开发和智能家居控制应用。

weixin_28736355的博客 438

GDUT_排位赛题解报告_第5场_C. 积木

题目: ChenJr已经两个月没有出门了,因此他已经无聊到开始用积木来玩搭房子游戏了。 ChenJr首先规定,对于搭建的每一栋房子,他只能选取长度为n的积木作为地基,之后他根据下述的规则进行搭建。 如果当前搭建的房子的最顶端的积木块的长度为k,那么ChenJr可以选择一个正整数i,(i∈[1,k2]),并在房子顶端放置一个长度为i的积木。或者ChenJr可以选择不再继续放置积木,代表当前的房子已经...

DevourPower的博客 354

小程序强制更新避坑指南:手把手教你实现无缝升级

本文详细解析小程序强制更新的实现方法,重点介绍wx.getUpdateManager API的使用技巧,帮助开发者规避冷热启动机制下的版本管理陷阱。通过实战案例展示如何设计多级更新提示策略,确保用户无缝升级,提升小程序版本更新率。

star的博客 280

Race(思维)

题目描述 Bessie is running a race of length K (1≤K≤109) meters. She starts running at a speed of 0 meters per second. In a given second, she can either increase her speed by 1 meter per second, keep it un...

eazo的博客 566

使用moveit!控制真实机械臂(5)——编写真实机械臂节点中的action服务程序

上一篇文章中,我们简要介绍了ROS中action的基本知识,为了控制真实机械臂,我们已经修改了moveit配置文件,使得moveti启动后具备一个control_msgs::FollowJointTrajectoryAction类型的action客户端,接下来,我们完成该类型action的另一半,编写C++程序来实现action的服务端。由于底层机器人控制程序一般差别都很大,这里展示的只是编程要点...

爱学习的草莓熊 1万+

RK3568平台开发系列:Android环境下CAN的使用

在RK3568平台上,我们可以利用Android环境中的API来实现CAN的使用。通过以上步骤,我们可以在Android应用中发送和接收CAN数据,并进行相应的处理。当接收到CAN数据时,将触发onMessageReceived回调方法,我们可以在这个方法中对接收到的数据进行处理。在上述代码中,我们指定了CAN的ID为0x123,数据为{0x01, 0x02, 0x03},并设置了标志位和周期。接收CAN数据需要注册一个监听器,并在监听器中处理接收到的数据。发送CAN数据需要指定CAN的ID和数据。

2301_79330513的博客 1912

排位赛3-Race

排位赛3-Race 题目 Bessie is running a race of length K (1≤K≤109) meters. She starts running at a speed of 0 meters per second. In a given second, she can either increase her speed by 1 meter per second, ke...

weixin_45600829的博客 517

Open3D 读取、保存、显示点云【2025最新版】

paint_uniform_color给所有的点上一个统一的颜色。博客长期更新,本文最近更新时间为:2025年1月1日。

点云侠的博客 37万+

D. Race

GDUT 2020寒假训练 排位赛三 D 原题链接 D. Race 题目 outputstandard output Bessie is running a race of length K (1≤K≤109) meters. She starts running at a speed of 0 meters per second. In a given second, she can ei...

xcy2001的博客 519

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

Running(POJ-3661)

Problem Description The cows are trying to become better athletes, so Bessie is running on a track for exactly N (1 ≤ N ≤ 10,000) minutes. During each minute, she can choose to either run or rest for...

Alex_McAvoy的博客 609

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

GDUT_排位赛题解报告_第5场_H. 完美排列

题目: ChenJr定义一个长度为n的完美排列为:对于一个任意的的i,都有a[i−1]>a[i]<a[i+1] 或者 a[i−1]<a[i]>a[i+1] 给你一个正整数n,你需要输出一个字典序最小的完美排列。 Input 一行输入一个正整数n (1≤n≤105)。 Output 输出n个整数,代表答案的排列。 Example inputCopy 1 outputCopy ...

DevourPower的博客 461

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

USACO-赛跑

目录题意样例题解代码 题意 Bessie 正在参加一场 K 米的跑步比赛。 她从 0 米每秒的速度开始比赛。 在每一秒中,她可以选择将她的速度增加 1 米每秒,保持速度不变,或者将她的速度减少 1 米每秒。 例如,在第一秒中,她可以将她的速度增加到 1 米每秒,跑 1 米,或者保持她的速度 0 米每秒不变,跑 0 米。 Bessie 的速度不会降低到小于零。 Bessie 始终朝着终点线的方向跑,她想要花费整数秒的时间完成比赛。 此外,她不想在终点时跑得太快:在 Bessie 跑完 K 米的时刻,她希望她的

nsuCony 788

2020 GDUT Rating Contest III (Div. 2) D. Race

来源 codeforces 2020 GDUT Rating Contest III (Div. 2) CF链接 题目: Bessie is running a race of length K (1≤K≤109) meters. She starts running at a speed of 0 meters per second. In a given second, she can ei...

qq_39581539的博客 212

Photoshoot(模拟)

题目描述 Farmer John is lining up his N cows (2≤N≤103), numbered 1…N, for a photoshoot. FJ initially planned for the i-th cow from the left to be the cow numbered ai, and wrote down the permutation a1,a2,...

eazo的博客 1182

2020.2.25GDUT寒假训练排位赛3-D

D — Race 题目大意: 贝西正在进行一场长度为K(1≤K≤109)米的赛跑。她刚开始以每秒0米的速度跑。在给定的一秒内,她可以把速度提高1米/秒,或者保持不变,或者降低1米/秒。例如,在第一秒,她可以把速度提高到1米/秒,然后跑1米,或者保持0米每秒,然后跑0米。贝西的速度永远不会降到0以下。 贝西总是跑向终点线,她希望在整数秒后完成(在这个整数秒内结束或超过终点线)。此外,她不想在终点线跑...

csdn_xieql的博客 393

【牛客——牛客假日团队赛8】J-Running

链接:https://ac.nowcoder.com/acm/contest/1069/J 来源:牛客网 题目描述 The cows are trying to become better athletes, so Bessie is running on a track for exactly N (1 ≤ N ≤ 10,000) minutes. During each minute...

A-lex的博客 290

TOJ 比赛C题 Visiting Cows (TJU 2011 Exercise Contest 04)

C.   Visiting CowsTime Limit: 1.0 Seconds   Memory Limit: 65536K<br />Total Runs: 61   Accepted Runs: 21    Multiple test files<br /><br /><br />Description<br />After many weeks of hard work, Bessie is finally getting a vacation! Being the most social cow

bingshen的专栏 1127

GDUT_寒假训练题解报告_专题I_L题 个人题解报告

GDUT_寒假训练题解报告_专题I_L题 个人题解报告 题目: You are given two integers a and b. You may perform any number of operations on them (possibly zero). During each operation you should choose any positive integer x and...

DevourPower的博客 880

GDUT_寒假训练题解报告_专题I_K题 个人题解报告:杭电题目Error Curves【裸三分】

GDUT_寒假训练题解报告_专题I_K题 个人题解报告 题目: Josephina is a clever girl and addicted to Machine Learning recently. She pays much attention to a method called Linear Discriminant Analysis, which has many interesti...

DevourPower的博客 702

GDUT_寒假训练题解报告_专题I_A题 个人题解报告【尺取模板题目详解】【poj题目Subsequence】

GDUT_寒假训练题解报告_专题I_A、B、C、D题 个人题解报告 A题:尺取(模板题目 给出了一个N个正整数序列(10<N<1e5),每个正整数小于或等于10000,以及一个正整数S(S<1e8)。编写一个程序,以求序列的连续元素的子序列的最小长度,其和大于或等于S。 输入 第一行是测试用例的数量。对于每个测试用例,程序必须从第一行读取数字N和S,用间隔分隔。序列的数目在测试用...

DevourPower的博客 557

GDUT_排位赛题解报告_第3场_H. Photoshoot

题目: Farmer John is lining up his N cows (2≤N≤103), numbered 1…N, for a photoshoot. FJ initially planned for the i-th cow from the left to be the cow numbered ai, and wrote down the permutation a1,a2,…...

DevourPower的博客 525
上一篇: GDUT_排位赛题解报告_第2场_Fence Planning
下一篇: GDUT_排位赛题解报告_第3场_H. Photoshoot
DevourPower
博客等级 码龄7年 52粉丝 78原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值