HZAU--19--Eat Candy(水题)
来源:互联网 发布:php 数组写法 编辑:程序博客网 时间:2024/05/16 07:47
Eat Candy
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1333 Solved: 644
[Submit][Status][Web Board]
Description
There is a box with infinite volume. At first there are n candies in the box. Then every second you will eat some candies, left half of candies (round down) in the box. Then add k candies into the box. How many candies there are in the box after 109+7 seconds?
Input
There are multiple test cases. In each test case, there are only one line contains two integersn,k(1≤n,k≤109+7)
Output
For each test case, output the answer in one line.
Sample Input
4 52 3
Sample Output
95
HINT
In the first test case:
1st second, 4->2, 2+5 = 7
2nd second, 7->3, 3+5 = 8
3rd second, 8->4, 4+5 = 9
4th second, 9->4, 4+5 = 9
…
1000000007th 9
So there are 9 candies in the box after 1000000007 seconds.
非常水的一道题,不解释了
#include<cstdio>#include<cstring>#include<iostream>#include<algorithm>using namespace std;int main(){long long n,k;while(scanf("%lld%lld",&n,&k)!=EOF){long long ans=n;for(int i=0;i<1e9+7;i++){n=n/2+k;if(ans==n){break;}ans=n;}printf("%lld\n",ans);}return 0;}
0 0
- HZAU--19--Eat Candy(水题)
- HZAU 1017 Eat Candy
- Problem H: Eat Candy
- Problem H: Eat Candy
- Problem H: Eat Candy
- Problem H: Eat Candy
- hzauoj Problem H: Eat Candy (暴力)
- HZAU oj 1015(LCS)
- HZAU 1209 Deadline (技巧)
- eat
- eat
- uva 10273 - Eat or Not to Eat?(暴力枚举)
- UVA 10273 - Eat or Not to Eat?(暴力)
- UVA10273 - Eat or Not to Eat?(暴力)
- HZAU校赛F题 LCS (dp)
- HZAU--21--Arithmetic Sequence(二维dp)
- HZAU--20--Catching Dogs(模拟)
- HZAU 1208 Color Circle (dfs)
- Synchronized
- 连接数据库超时设置autoReconnect=true
- Box2d源码学习<三> 内存管理之栈的实现
- Ionic开发中注意事项(持续更新)
- JavaWeb不错的教程01
- HZAU--19--Eat Candy(水题)
- 进程概述和内存分配
- 使用RTEMS Source Builder 编译RTEMS-4.11的开发工具链
- 关于ConcurrentModificationException的个人观点
- Linux国内常用源的介绍和使用(Ubuntu16.04为例)
- 2016网易游戏暑假实习第一场·第一题
- 浅谈 EventBus
- vs using不出MySql.Data.MySqlClient;的解决
- 图灵机器人程序编写得具体步骤,适合刚学习了网络基础的人