Codeforces Round #476 (Div. 2) [Thanks, Telegram!] C. Greedy Arkady

NVIDIA DRIVE SDK深度解析(一)——核心组件与安全架构设计 本文深度解析NVIDIA DRIVE SDK的核心组件与安全架构设计,涵盖DriveOS、加速库和应用框架三层架构,以及虚拟化与安全隔离机制。重点探讨了安全岛设计、媒体处理流水线和功能安全监控体系,为开发者提供自动驾驶系统开发的实战建议和性能优化技巧。 阅读详情
C. Greedy Arkady
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

kk people want to split nn candies between them. Each candy should be given to exactly one of them or be thrown away.

The people are numbered from 11 to kk, and Arkady is the first of them. To split the candies, Arkady will choose an integer xx and then give the first xx candies to himself, the next xx candies to the second person, the next xx candies to the third person and so on in a cycle. The leftover (the remainder that is not divisible by xx) will be thrown away.

Arkady can't choose xx greater than MM as it is considered greedy. Also, he can't choose such a small xx that some person will receive candies more than DD times, as it is considered a slow splitting.

Please find what is the maximum number of candies Arkady can receive by choosing some valid xx.

Input

The only line contains four integers nn, kk, MM and DD (2≤n≤10182≤n≤1018, 2≤k≤n2≤k≤n, 1≤M≤n1≤M≤n, 1≤D≤min(n,1000)1≤D≤min(n,1000), M⋅D⋅k≥nM⋅D⋅k≥n) — the number of candies, the number of people, the maximum number of candies given to a person at once, the maximum number of times a person can receive candies.

Output

Print a single integer — the maximum possible number of candies Arkady can give to himself.

Note that it is always possible to choose some valid xx.

Examples
input
Copy
20 4 5 2
output
Copy
8
input
Copy
30 9 4 1
output
Copy
4
Note

In the first example Arkady should choose x=4x=4. He will give 44 candies to himself, 44 candies to the second person, 44 candies to the third person, then 44 candies to the fourth person and then again 44 candies to himself. No person is given candies more than 22 times, and Arkady receives 88 candies in total.

Note that if Arkady chooses x=5x=5, he will receive only 55 candies, and if he chooses x=3x=3, he will receive only 3+3=63+3=6 candies as well as the second person, the third and the fourth persons will receive 33 candies, and 22 candies will be thrown away. He can't choose x=1x=1nor x=2x=2 because in these cases he will receive candies more than 22 times.

In the second example Arkady has to choose x=4x=4, because any smaller value leads to him receiving candies more than 11

 time

.

题解:
因为d在1000之内,可以枚举d,对于每个d,可以把
n划分为(d-1)*k~d*k块,二分查找即可。
代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,k,m,d;
    scanf("%lld%lld%lld%lld",&n,&k,&m,&d);
    ll ans=0;
    for(ll t=1;t<=d&&t*k<=n;t++)
    {
        ll l=(t-1)*k,r=t*k;
        while(r-l>1)
        {
            ll mid=(r+l)/2;
            if(n/(mid+1)<m)r=mid;
            else l=mid;
        }
        ans=max(ans,min(n/r*t,t*m));
    }
    printf("%lld\n",ans);
    return 0;
}

别再纠结Dify了!实测对比RAGFlow和Dify,聊聊企业知识库到底该怎么选 本文深度对比了RAGFlow和Dify在企业知识库选型中的实际表现,从技术架构、性能指标、部署成本等多维度进行分析。RAGFlow在复杂文档处理和准确率方面表现突出,适合有专职技术团队的企业;而Dify则以低门槛和快速部署见长。文章提供了六维度评估法,帮助企业根据文档复杂度、准确率要求等技术指标做出明智选择。 阅读详情

相关推荐

Vue+ECharts-GL 3D地图实战:5层叠加打造炫酷中国地图(附完整代码)

本文详细介绍了如何利用Vue和ECharts-GL构建具有强烈立体感的3D中国地图。通过5层图层的巧妙叠加与样式调校,实现了从背景阴影到交互高光的完整视觉层次,并整合了动态飞线与散点标记。文章提供了完整的代码实现、核心配置解析以及性能优化与视觉调优的实战技巧,帮助开发者快速打造专业级的交互式地图可视化应用。

d6e7f8g9h的博客 659

Greedy Arkady(思维)

k people want to split n candies between them. Each candy should be given to exactly one of them or be thrown away.The people are numbered from 1 to k, and Arkady is the first of them. To split the ca...

to的博客 345

SHP转TXT、TXT转SHP工具(附工具下载链接)

关于TXT,可以选择整个图层生成一个TXT。也可以勾选“每个地块单独存TXT”,然后选择一个字段,根据字段值,给每个地块生成一个TXT文件。支持选择和数据框一样的坐标系,也可以选择一个图层,工具会采用和这个图层一样的坐标系。1、TXT数据支持输入单个或者多个TXT文件,也可以直接选择TXT所在的文件夹。所有的TXT数据都生成到一个矢量数据图层。关于这一行的内容,可以在地块坐标行设置中进行设置。其他:①面节点闭合:勾选,则回到起点。属性描述:可以直接复制粘贴进来,也可以直接修改。也可以改为任意字母。

坐听风雨 4343

2018/7/20 CF#476 C. Greedy Arkady

题目描述: kk people want to split nn candies between them. Each candy should be given to exactly one of them or be thrown away. The people are numbered from 1 to k, and Arkady is the first of them. To s...

slark_的博客 282

大数据应用技术实验报告一 Hadoop三种模式安装配置

JDK+Hadoop安装配置、单机模式配置 以下操作在SecureCRT里面完成 1.关闭防火墙 firewall-cmd --state 显示防火墙状态running/not running systemctl stop firewalld 临时关闭防火墙,每次开机重新开启防火墙 systemctl disable firewalld 禁止防火墙服务。 2.传输JDK和HADOOP压缩包 Sec...

Ruthless_Childe的博客 3106

5G MBS(组播广播服务)深度解析:从标准架构到商用实践

5G MBS(组播广播服务)深度解析:从标准架构到商用实践

大家好,我是码农老gou,一名专注于编程技术的程序员。在这个博客中,我将与大家分享我在工作和学习中的经验、见解以及一些实用的技术干货。 1093

C. Greedy Shopping(线段树+复杂度分析)

题目 题意:     有n个商店,每个商店吃一顿饭需要a[i]元,保证a[i]单调不减。现在有q次操作:     操作1:1 x y,表示将区间[1,x]的a[i]变为max(a[i],y);     操作2:2 x y,现在有一个人有y元钱,从x个商店开始,如果能吃饭,就花费a[i]元钱吃一顿,否则就不吃去下一家,一直到第n家,输出一共能吃多少顿。     1≤n≤2e5,1≤q≤2e5。1≤n≤2e5,1≤q≤2e5。1≤n≤2e5,1≤q≤2e5。 分析:     首先这个是对区间进行操作,我们可以很

weixin_44316314的博客 247

【WRF安装(2025)】服务器移植 WRF 安装环境

【WRF安装(2025)】服务器移植 WRF 安装环境

WW、forever的博客 111

C. Greedy Arkady

kkpeople want to splitnncandies between them. Each candy should be given to exactly one of them or be thrown away. The people are numbered from11tokk, and Arkady is the first of them. To...

weixin_30914981的博客 200

如何设置反馈点

前面的POWER DC仿真都是忽略反馈线进行的仿真,如果单板压降不过,电源会自动调整输出电压,来满足负载的得到额定的电压.可以看到因为设置了反馈点,源端电压就被抬高到满足压降的值了。仿真上也可以自己添加反馈点,以得到抬高后的电源输出电压值。同样以下图的CPU的Core电源为例。按照流程正常设置好参数。

weixin_54787054的博客 1151

RK3576 USB3.0 DWC3控制器调试:PHY初始化失败排查指南

DWC3 是 Synopsys 公司推出的 USB3.0/3.1 控制器 IP,支持双角色(DRD)模式,可配置为 Host、Device 或 OTG。

小灰灰的博客 1193

Codeforces1439 C. Greedy Shopping(线段树)

题意: 给定长度为n的序列a,保证给定的序列非递增。 q次操作,操作有两种: (1,x,y):将[1,x]的所有数变为max(a[i],y) (2,x,y):从x位置开始向右走到n,假设在pos位置遇到一个<=y的数,那么ans++,y-=a[pos],输出ans. 数据范围:n,q<=2e5 ...

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 289

11.嵌入式控制器EC实战 KBC矩阵键盘Keyboard开发流程

文章目录笔记本矩阵键盘概述矩阵键盘的扫描方式行列扫描方式逐行逐列扫描方式EC中矩阵键盘是如何扫描并得到码值的(代码分析) 笔记本矩阵键盘概述 在EC中支持两种形式的键盘,一种是PS/2接口的键盘,这种键盘几乎已经被USB接口的键盘所取代,所以PS/2接口的键盘不在我们的讨论范围。 另一种键盘则是矩阵键盘,也是笔记本电脑的内置键盘,该键盘类似于学习单片机时使用的4*4的那种键盘,笔记本使用的矩阵键盘有三种规格,分别是16*8、17*8和18*8。16、17和18代表着该款键盘的列数,8代表着键盘的行数,我们这

qq_30135687的博客 3814

【Codeforces Round #476 (Div. 2) [Thanks, Telegram!] C】Greedy Arkady

【链接】 我是链接,点我呀:) 【题意】 在这里输入题意 【题解】 枚举那个人收到了几次糖i. 最好的情况显然是其他人都只收到i-1次糖。 然后这个人刚好多收了一次糖 也即 (i-1)kx + x <= n 显然x越大越好。 那么直接令\(x=\frac{n}{( (i-1)*k+1)}\)就好 如果x>M了 那么令x = M; 但这个时候。 要判断一下改变之...

AWCXV 121

IEM模型,地表粗糙度模拟

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

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

Codeforces Round #476 (Div. 2) [Thanks, Telegram!] C. Greedy Arkady(brute force/math)

C. Greedy Arkady 传送门 这题的关键就是算出自己一共receive了多少次,我们可以很容易的便推出这么一个式子—&gt;(nx+k−1)k(nx+k−1)k\frac{(\frac{n}{x}+k-1)}{k} 之后嘛暴力二分一下就好啦 #include&lt;cstdio&gt; #include&lt;iomanip&gt; #include&lt;cstring&...

喵喵喵? 860

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

codeforces 965c Greedy Arkady (思维题)

C. Greedy Arkady time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output kk people want to split nn candies between them. Each candy shoul...

yjt9299的博客 815

C - Greedy Arkady

点我吧,我在这k people want to split n candies between them. Each candy should be given to exactly one of them or be thrown away.The people are numbered from 1 to k, and Arkady is the first of them. To split...

AC_AC_的博客 470

Codeforces Round #476 (Div. 2) C. Greedy Arkady(二分)

C. Greedy Arkady time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output k people want to split n candies b...

weixin_30239339的博客 158

数学--数论--HDU - 6322 打表找规律

In number theory, Euler's totient function φ(n) counts the positive integers up to a given integer n that are relatively prime to n. It can be defined more formally as the number of integers k in the ...

日拱一卒,功不唐捐 2781

Codeforces Round #476 (Div. 2) C. Greedy Arkady

点击打开题目链接知道了当第一个人比那 k-1 个人多分一次x就是最优策略 和 对分糖果的次数进行枚举就差不多了当分i次的时候,有 (i-1)*x(k-1)+x+i&lt;=n;x=n/((i-1)*k+1)不过当枚举到 i 次 x&gt;m 的时候要重新对这个分i进行判断,此时 x 就等于最大值 m 了,要是还可以得出能够在分 i 次的结果,就可以对这个 i*m 进行判断了#include &lt...

sxy201658506207的博客 263

Div Times Mod

                                                                         Div Times Mod Vasya likes to solve equations. Today he wants to solve (x div k)⋅(xmodk)=n(x div k)⋅(xmodk)=n , where divdiv an...

Sky丨Star的博客 716

Codeforces Round #476 (Div. 2) D. Single-use Stones

D. Single-use Stones time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A lot of frogs want to cross a river. A river is ww units wid...

ii0789789789的博客 298

Codeforces Round #684 (Div. 2) 简要题解

脑子需要清楚,不要乱写

Irving0323的博客 1226

E. Greedy Shopping

E. Greedy Shopping 解题思路:这题用线段树。有两种操作,操作1:对于1~x的范围a[i] = max(a[i],y),,因为整个区间不是递减的,所以只要找到区间中第一个小于等于y的坐标位置k,在[k,x]这段区间肯定就为y,用lazy数组记录一下。对于操作2:查询的方法从[x,y]先找到一段区间和<=c,统计一下他们的结果,并把这个和返还回去,用c-这个区间和,得到了另外一个c,再从这个区间找到第一段区间和<=c…,直到不能操作为止。 #include <bits/std

多一些不为什么的坚持 453

E. Greedy Shopping 线段树

link 比较裸的线段树了吧,不过没写出来还是有点思路不清楚,对线段树理解还是不够。 对于操作1,可以看成区间覆盖,维护一个区间最大值和最小值,最小值用来剪枝,让后大于最大值的时候覆盖掉即可。 对于操作2,当当前区间sum<=x的时候,说明可以直接减去。否则的话先递归左区间,让后递归右区间,依次处理即可。 实现起来就so easy了。 //#pragma GCC optimize(2) #include<cstdio> #include<iostream> #include&l

DaNIelLAk的博客 1891

Codeforces Round #481 (Div. 3) F. Mentors

F. Mentorstime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIn BerSoft nn programmers work, the programmer ii is characterized by a skill riri.A pro...

qq_36603180的博客 389

1439C Greedy Shopping(线段树+思维)

Codeforces Round #684 (Div. 2) E. Greedy Shopping

月巴虫丰博客 391
上一篇: 第15届浙江省赛 E LIS
下一篇: Codeforces Round #476 (Div. 2) [Thanks, Telegram!] D. Single-use Stones
还是太年轻
博客等级 码龄9年 53粉丝 552原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值