hzauoj Problem H: Eat Candy (暴力)
来源:互联网 发布:迅雷你的网络未连接 编辑:程序博客网 时间:2024/05/22 17:10
Problem H: 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 addk candies into the box. How many candies there are in the box after 109+7seconds?
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 pre=n;for(int i=0;i<1e9+7;i++){n=n/2+k;if(pre==n){break;}pre=n;}cout<<n<<endl;}return 0;}
0 0
- hzauoj Problem H: Eat Candy (暴力)
- Problem H: Eat Candy
- Problem H: Eat Candy
- Problem H: Eat Candy
- Problem H: Eat Candy
- HZAU 1017 Eat Candy
- hzauoj Problem I: Catching Dogs (数学模拟)
- hzauoj Problem J: Arithmetic Sequence (dp)
- HZAU--19--Eat Candy(水题)
- 3991 H. Eat or Study
- uva 10273 - Eat or Not to Eat?(暴力枚举)
- UVA 10273 - Eat or Not to Eat?(暴力)
- UVA10273 - Eat or Not to Eat?(暴力)
- UVA - 10273 Eat or Not to Eat? 暴力
- Eat or Not to Eat? - UVa 10273 暴力
- Problem F: 二进制类(1)__运算符重载 hzauoj
- [暴力]cf229CInna and Candy Boxes
- eat
- C++内存分布 虚表 虚指针(非常重要)
- Java 常用排序算法
- 浅谈 EOF,BOF
- 杂记 - 老书店
- 智能网联汽车发展现状与趋势分析
- hzauoj Problem H: Eat Candy (暴力)
- 第7课:Spark Streaming源码解读之JobScheduler内幕实现和深度思考
- Angular入门2
- Building Web Apps in WebView
- 使用MATLAB工具箱TOOLBOX_calib标定摄像头过程
- Linux is not Matrix——日志搜集平台ELK(I)
- 搭建一个私有registry服务(基础版本)
- 归纳法证明汉诺塔解析式思路
- 67. Add Binary