Problem H: Eat Candy
来源:互联网 发布:java删除压缩文件 编辑:程序博客网 时间:2024/05/29 07:58
Problem H: Eat Candy
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1329 Solved: 643
[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 integers n,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<stdio.h>#include<string.h>#include<math.h>int main(){long a,b,i,re,t;while(scanf("%ld %ld",&a,&b)!=EOF){re=a/2;while(1){t=re;re+=b;re=re/2;if(t==re){printf("%ld\n",t+b);break;}}}return 0;}
0 0
- Problem H: Eat Candy
- Problem H: Eat Candy
- Problem H: Eat Candy
- Problem H: Eat Candy
- hzauoj Problem H: Eat Candy (暴力)
- HZAU 1017 Eat Candy
- HZAU--19--Eat Candy(水题)
- 3991 H. Eat or Study
- eat
- eat
- Problem H
- Problem H
- Problem H
- Problem H
- Problem H
- Problem H
- Problem H
- problem h
- java学习地图
- Hadoop map与reduce数量
- CodeForces 510B Fox And Two Dots(DFS)
- 修改oracle数据库用户名及密码的方法
- 什么是Dubbo
- Problem H: Eat Candy
- android生成随机汉字
- SETSOCKOPT IOCTLSOCKET 设置非阻塞SOCKET函数
- @RequestParam @RequestBody @PathVariable 等参数绑定注解详解(转载)
- 眼动跟踪
- 小团队,个人任务没完成导致团队加班是否应该赞赏?
- SSH框架
- cocos2d-x 坐标转换总结
- 华中农业大学第四届程序设计大赛网络同步赛题目