CF991C Candies

XX联通SF4810宕机+VCS资源offline处理过程总结文档 湖北联通SF4810异常宕机,VCS资源无法自动切换,计费采集业务中断. 系统版本:solaris 10 VCS版本:5.0 VXVM版本:5.0 二、处理过程 2.1检查硬件、启系统到达现场检查发现IB6、RP0、RP2故障: sun4810_sc1:SC> showlog -v Mar 14 09:53:10 sun4810_sc1 Platform.SC: [ID 846693 local0.notice] Device will not be polled Mar 14 09:53:10 sun48 阅读详情

原题链接:http://codeforces.com/contest/991/problem/C

Candies

After passing a test, Vasya got himself a box of n n candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided to get some candies for himself.

This means the process of eating candies is the following: in the beginning Vasya chooses a single integer k, same for all days. After that, in the morning he eats k k candies from the box (if there are less than k candies in the box, he eats them all), then in the evening Petya eats 10% 10 % of the candies remaining in the box. If there are still candies left in the box, the process repeats — next day Vasya eats k k candies again, and Petya — 10% of the candies left in a box, and so on.

If the amount of candies in the box is not divisible by 10 10 , Petya rounds the amount he takes from the box down. For example, if there were 97 97 candies in the box, Petya would eat only 9 9 of them. In particular, if there are less than
10 candies in a box, Petya won’t eat any at all.

Your task is to find out the minimal amount of k k that can be chosen by Vasya so that he would eat at least half of the n candies he initially got. Note that the number k k must be integer.

Input

The first line contains a single integer n (1≤n≤1018) ( 1 ≤ n ≤ 10 18 ) — the initial amount of candies in the box.

Output

Output a single integer — the minimal amount of k k that would allow Vasya to eat at least half of candies he got.

Example
input

68

output

3

Note

In the sample, the amount of candies, with k=3, would change in the following way (Vasya eats first):

68→65→59→56→51→48→44→41→37→34→31→28→26→23→21→18→17→14→13→10→9→6→6→3→3→0 68 → 65 → 59 → 56 → 51 → 48 → 44 → 41 → 37 → 34 → 31 → 28 → 26 → 23 → 21 → 18 → 17 → 14 → 13 → 10 → 9 → 6 → 6 → 3 → 3 → 0 .

In total, Vasya would eat 39 39 candies, while Petya — 29 29 .

题解

因为每次糖果都会缩水 10% 10 % , 1018 10 18 只要 300 300 多次就没了,那么就愉快的二分答案吧,复杂度 O(log2n×log1091018) O ( l o g 2 n × l o g 10 9 10 18 ) 。

代码
#include<bits/stdc++.h>
using namespace std;
long long n,le,ri,mid;
bool check(long long k)
{
    long long less=0,res=n;
    for(;res>0;res-=k,less+=(res>0?res:0)/10,res-=res/10);
    return less<=n/2;
}
void in(){scanf("%I64d",&n);}
void ac()
{
    le=1,ri=n/2+1;
    while(le^ri)mid=le+ri>>1,check(mid)?ri=mid:le=mid+1;
    printf("%I64d",le);
}
int main(){in();ac();}
搭建多地域共享存储 前言 最近,隔壁部门的工程师小刘正在探索如何搞一套支持多地域容灾、且能共享访问的文件服务解决方案。在之前他尝试过本地的NAS存储,无奈扩容艰难、远程访问性能和吞吐量都很受限,管理复杂且成本高昂,多地备份服务更是代价巨大。其实这些功能,利用腾讯云的公有云基础服务,简单几步就可以实现。这篇小教程中,将和大家一起轻松探索,在腾讯云上搭建高可用的共享存储解决方案。 今天这篇教程的主角是CVM、VPC、CFS等腾讯云IaaS层的核心基础服务。 云服务器和私有网络创建 作为预热,本节我们将在创建VPC(以及相关的子网) 阅读详情

相关推荐

从原理图到PCB:基于Allegro的8槽PXIe背板高速设计实战

本文详细介绍了基于Allegro软件进行8槽PXIe背板高速设计的完整实战流程。从理解规范、原理图设计、PCB布局规划,到高速PCIe差分对与精密时钟的布线艺术,再到电源与地处理以及最终的设计验证与生产文件输出,系统性地阐述了确保背板信号完整性、电源完整性和系统稳定性的关键技术与工程实践。

weixin_28312391的博客 208

CF991C

题解: 很显然不会有那么多种肯能 所以都列出来即可 代码: #include<bits/stdc++.h> using namespace std; int main() { int k[3]; scanf("%d%d%d",&k[1],&k[2],&k[3]); sort(k+1,k+4); ...

a5199519的博客 184

SDRAM控制器——添加读写FIFO

用FIFO实现数据缓存

H19981118的博客 2627

cf 991c || div2491 c

本题网址:http://codeforces.com/problemset/problem/991/C 算法很明显 直接去二分答案就行 然后计算看是不是满足大于等于一半的糖果 是的话r=mid 否则 l=mid 二分细节很多 我这里是左右各扩了一个点 因为最少肯定是吃一个 所以左扩一个点后l=0 #include<bits/stdc++.h> using namespace std...

菜鸡的学习记录 253

1.30 Cubemx_STM32H743 SD_Card纳入文件管理系统

Cubemx_STM32H743 SD_Card纳入文件管理系统1、简介2、CubeMX配置 1、简介 和前面文章原理其实一样的。 1.29 Cubemx_STM32F429\H743 nandflash、spifalsh纳入文件管理系统 现在一并将SD卡、NandFlash、SPIFlash一并作为文件管理。 下面直接介绍SDcard,其他参考前面文章。 2、CubeMX配置 ...

oDuanYanGuHong的博客 1080

Arduino——GY39大气压、温湿度、光照模块

前几天买东西的时候买了一个GY39,这个模块集成了温湿度,大气压,海拔,光照一体,使用起来很方面。它有两种工作模式使用串口模式时需要搭配转接板,我选择了IIC模式,看一下通信协议吧,就是关于高八位和低八位的数据。看一下接线。

戚晨夕的博客 2605

CF991C Candies 二分 第十五

Candies time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output After passing a test, Vasya got himself a box ofnncandies....

weixin_33716557的博客 246

[特殊字符] 智能补货(AI-driven Replenishment)完整实施方案

补货量=预测需求+安全库存−当前库存补货量 = 预测需求 + 安全库存 - 当前库存补货量=预测需求+安全库存−当前库存。:基于 LSTM/Transformer 预测未来 30/60/90 天的销量。

nbsaas-boot基于Request-Response的企业级快速开发框架 969

CF思维联系– CodeForces - 991C Candies(二分)

After passing a test, Vasya got himself a box of n candies. He decided to eat an equal amount of candies each morning until there are no more candies. However, Petya also noticed the box and decided t...

日拱一卒,功不唐捐 3089

基于FPGA的DDS信号发生器

之前的博客讲到了DDS的基本原理,现在用Verilog代码实现DDS,能够产生四种波形,方波,三角波,正弦波,锯齿波,用按键来控制频率和选择波形。其中按键消抖模块来自小梅哥的FPGA自学笔记设计与验证这本书。 module DDS_Module( Clk, Rst_n, EN, Fword, Key1, Pword, DA_Clk, DA_Data ); input Clk...

qq_43534451的博客 9950

利用ANSYS随机振动分析功能实现随机疲劳分析

本文介绍了ANSYS随机振动分析功能,以及利用该功能,按照Steinberg提出的基于高斯分布和Miner线性累计损伤定律的三区间法进行ANSYS随机疲劳计算的具体过程。在工程应用中,汽车、飞行器、船舶以及其它各种机械或零部件,大多是在随机载荷作用下工作,当它们承受的应力水平较高,工作达到一定时间后,经常会突然发生随机疲劳破坏,往往造成灾难性的后果。因此,预测结构或零部件的随机疲劳寿命是非常有必要的。在工程界,疲劳计算广泛采用名义应力法,即以S-N曲线为依据进行寿命估算的方法,可以直接得到总寿命。

qq_38220914的博客 7614

Codeforces Round #491 (Div. 2):C. Candies(二分)

C. Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter passing a test, Vasya got himself a box of nn candies. He decided to eat an equal a...

加载中... 929

【FPGA教程案例59】深度学习案例6——基于FPGA的CNN卷积神经网络之整体实现

在课程,我们对的基本原理有了初步认识。在上一个课程,我们完成了CNN的Relu激活层、pool池化层、卷积层以及图像输入层的实现,如下图所示:在本课程中,我们将上述四个模块结合起来,构建一个简单的CNN卷积神经网络。...

FPGA/MATLAB学习教程/源码/项目合作开发 2637

C. Candies(二分)

C. Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter passing a test, Vasya got himself a box of nn candies. He decided to eat an equal a...

JiaYao的博客 868

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

POJ 3159 Candies

Candies Time Limit: 1500MS   Memory Limit: 131072K Total Submissions: 19693   Accepted: 5196 Description During the kindergarten days, flymouse was the monitor of his cla

ACM2272902662的专栏 1240

数学建模模型总结

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

CodeForces ~ 991C ~ Candies(二分)

题意 有N个糖果,Vasya每天早起吃k个,Petya每天晚上吃%10。Vasya至少要吃一半,最小的k为多少? 思路 二分答案,注意开long long,奇数的情况,n=1的时候。 #include &lt;bits/stdc++.h&gt; using namespace std; const int MAXN = 105; typedef long long ll; ll n, ...

张松超的博客 873

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

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

C. Candies

C. Candiestime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAfter passing a test, Vasya got himself a box of n candies. He decided to eat an equal am...

fbher的博客 769

mount (挂载命令)详解

标题:linux mount (挂载命令)详解 2010-01-18 10:43:09 挂接命令(mount)  首先,介绍一下挂接(mount)命令的使用方法,mount命令参数非常多,这里主要讲一下今天我们要用到的。  命令格式:mount [-t vfstype] [-o options] device dir  其中:  1.-t vfsty

YJB666的专栏 7372

Codeforces 1189C Candies!

题目链接:http://codeforces.com/problemset/problem/1189/C 思路:前缀和。 AC代码: #include<bits/stdc++.h> using namespace std; const int maxn = 1e5 +5; int a[maxn]; int n, m; int ask(int x,int ...

weixin_30363981的博客 252

从mount -o一些理解结合cfs进行描述,窥探该项目全局。

mount命令中除了常见的-t 也就是选择挂在文件系统的类型。还有一个重要的参数-o 这个参数里面可以携带很多参数,比如设定挂在的用户名,密码等等,但是这些参数怎么接受呢,也就是具体会传递到哪里呢? 首先注册文件系统的时候,有个数据结构file_system_type 如cfs的文件系统定义如下: static struct file_system_type cfs_fs_type = {...

weixin_33885676的博客 1613

Candies CodeForces - 991C(二分别再错啦)、Bishwock CodeForces - 991D (D特简单)

/*题意大概就是减去x,再减去十分之一,找到最小能减去的那个数。这有什么呀..  首先担心会不会超了,写个小的先算一下,哪怕是1e18也只最多除三百次就除没了,二分是nlogn的,用起来应该没什么问题。然后开始写……错的很绝望,打开了花语学院……(划掉)【端点,端点,端点】(很严重!)(本场中的A,wa了一次其实应该注意到也是有端点的问题,每个都取到端点实验一次,是最起码的尊重……)那么问题出在哪...

lx233 448

CodeForces - 991C Candies(二分)

题干: 给定糖果数n。 Vasya每天早上起来吃i颗糖果,Petya每天晚上吃现有糖果数的十分之一(向下取整)(如果现有糖果数小于10则不吃)。 求Vasya 每天至少要吃多少糖果,才能在糖果被全部吃完时至少吃了一半的糖果。 1<=n<=1018{10}^{18}1018 思路: ...

苍界的博客 401

Three Piles of Candies(CF-1196A)

Problem Description Alice and Bob have received three big piles of candies as a gift. Now they want to divide these candies as fair as possible. To do this, Alice takes one pile of candies, then Bob...

Alex_McAvoy的博客 963

补题D题(Eat Candies)

#include <iostream> #include <bits/stdc++.h> using namespace std; int main() { int a[3]; int x; int n,i; cin>>n; int count; while(n--){ count = 0; memset(a,0,sizeof(a)); ...

qq_45793174的博客 484

Candies

Candies 题目来源1——VJ 题目来源2——洛谷 本文的题意大概是,Vasya 有n个糖,他会每天吃a块(如果不够a块就全部吃掉),但是他吃完之后,会有一个叫Petya的人来偷吃,每次吃所剩糖的1/10(如果不够就不吃了)。 输入总的糖数,问你Vasya每天最少吃几块糖,能够保证Vasya能够吃到总糖数n的一半或以上。 因为数据很大,所以遍历所有的数是不实际的,我们用到的想法很简单,就是二分...

weixin_43813647的博客 1289
上一篇: CF991B Getting an A
下一篇: CF991D Bishwock
ShadyPi
博客等级 码龄9年 1万+粉丝 637原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ShadyPi

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值