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;
}
cutlass2.x源码解读之PitchLinearStripminedThreadMap TensorCoord:使用layout::PitchLinearCoord作为张量坐标。Shape:使用模板参数Shape_作为tile的形状,kThreads:线程总数,定义为模板参数Threads。kElementsPerAccess:每次访问的元素数,定义为模板参数ElementsPerAccess。ThreadAccessShape:线程访问的形状,使用layout::PitchLinearShape定义。内部实现细节:ShapeVec。 阅读详情

相关推荐

STM32F407通过SMBus协议精准读取BQ40Z50电池电量

本文详细介绍了STM32F407通过SMBus协议精准读取BQ40Z50电池电量的实现方法。从硬件连接到软件驱动开发,再到通信异常排查,提供了完整的解决方案。重点解析了SMBus协议的特殊时序要求、GPIO模拟驱动的关键代码,以及实际调试中的常见问题与对策,帮助开发者高效完成电池管理系统开发。

weixin_29189003的博客 255

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的博客 370

在Termux上安装Kali Linux 完整系统

介绍如何在Termux上安装Kali Linux 完整系统

蓑雨一生的博客 2万+

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的博客 598

【PT+Arduino+OneNET基础教程1】PacketTracer中MCU芯片编程教程(零基础入门)

PacketTracer软件内MCU芯片编程入门 零基础

ChloeMax_的博客 9470

LLC谐振电路增益公式推导

LLC谐振电路增益公式理解

金凯*博客 1万+

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

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

DevourPower的博客 355

31、MSP430FR2355时钟系统与低功耗模式解析

本文详细解析了MSP430FR2355的时钟系统和低功耗模式。首先介绍了时钟系统的组成,包括XT1振荡器、DCO、MODCLK、MCLK、SMCLK和ACLK的功能与配置方法。接着探讨了MSP430FR2355的五种低功耗模式及其配置要点,并分析了时钟系统与低功耗模式之间的协同关系。最后通过实际应用案例展示了如何在具体场景中优化系统功耗。文章旨在帮助开发者充分利用MSP430FR2355的时钟与低功耗特性,实现高性能、低功耗的嵌入式系统设计。

mars5的博客 201

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的博客 568

地图自定义编码CSV转换成ini文件

创 建 schema.ini 文件:有时,当您尝试使用 .csv 文件将自定义地理信息导入 Tableau 时,您可能会看到“无法使用.csv,因为它不包含唯一列”错误消息。这是因为您的 .csv 文件可能包含数值数据,例如数值邮政编码。对于新的地理角色,Tableau 将只接受文本字段。但是,您可以创建一个 schema.ini 文件,以指示 Tableau 应将您要导入的数值字段视为文本字段。...

wenyusuran的专栏 1977

视觉SLAM十四讲slambook2示例代码所有依赖库的编译安装教程(VTK、OpenCV3、ceres、Sophus、g2o、Eigen、Pangolin、googletest等)

这是2021年的最后一篇博客~ 新年快乐! 0 准备工作   首先需要先安装cmake编译器: sudo apt-get install cmake   以及,将十四讲的示例代码克隆下来(十四讲的源码地址点击这里): git clone --recursive https://github.com/gaoxiang12/slambook2.git   由于里面的3rdparty文件夹内所有内容都来自于其他github仓库,所以需要加上--recursive参数,不然克隆下来的内容不完整。   如果你.

zeeq的博客 7840

排位赛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

用 Docker 一键部署 SillyTavern酒馆 mac/windows/linux通用教程,我再也不手动折腾了!

本文介绍了如何使用 Docker 一键部署 SillyTavern 项目,适用于 Mac、Windows 和 Linux 系统。SillyTavern 是一个本地部署的大语言模型聊天界面,支持多种插件和扩展。文章详细说明了安装 Docker、拉取项目、启动容器、配置白名单、启用插件等步骤,并提供了常见问题的解决方法。通过 Docker 部署,用户可以避免繁琐的手动配置,快速搭建和运行 SillyTavern,适合希望简化部署流程的用户。

代码简单说 Vue、JAVA、PHP、Node.js 熟练运用,接口、架构、性能全搞定。 2637

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的博客 522

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

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

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

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的博客 612

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

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的博客 1183

USACO-赛跑

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

nsuCony 788

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的博客 462

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

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

csdn_xieql的博客 393

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的博客 214

【牛客——牛客假日团队赛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

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的博客 703

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

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

DevourPower的博客 559

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的博客 526
上一篇: 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、付费专栏及课程。

余额充值