Eat Candy(暴力,水)
Eat Candy
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 8 Solved: 6
[Submit][Status][Web Board]
Description
There is a box with infinite volume. At first there are ncandies 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+7seconds?
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 5
- 2 3
Sample Output
- 9
- 5
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.
- import java.util.Scanner;
- public class EatCandy {
- public static void main(String[] args){
- int n, k;
- Scanner cin = new Scanner(System.in);
- while(cin.hasNext()){
- n = cin.nextInt();
- k = cin.nextInt();
- while(n != (n/ + k)){
- n = n / + k;
- }
- System.out.println(n);
- }
- }
- }
Eat Candy(暴力,水)的更多相关文章
- [Usaco2008 Feb]Line连线游戏[暴力][水题]
Description Farmer John最近发明了一个游戏,来考验自命不凡的贝茜.游戏开始的时 候,FJ会给贝茜一块画着N (2 <= N <= 200)个不重合的点的木板,其中第i ...
- Codeforces Round #280 (Div. 2) A B C 暴力 水 贪心
A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...
- Codeforces Round #409 (rated, Div. 2, based on VK Cup 2017 Round 2) A B C D 暴力 水 二分 几何
A. Vicious Keyboard time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- BZOJ4292 PA2015 Równanie 【暴力水题】
BZOJ4292 PA2015 Równanie Description 对于一个正整数n,定义f(n)为它十进制下每一位数字的平方的和.现在给定三个正整数k,a,b,请求出满足a<=n< ...
- Codeforces Round #321 (Div. 2)-A. Kefa and First Steps,暴力水过~~
A. Kefa and First Steps time limit per test 2 seconds memory limit per test 256 megabytes input stan ...
- hdoj--1716--排列2(暴力水题)
排列2 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...
- HDU 4691 正解后缀数组(暴力也能过)
本来是个后缀数组,考察算法的中级题目,暴力居然也可以水过,就看你跳不跳坑了(c++和G++返回结果就很不一样,关键看编译器) 丝毫不差的代码,就看运气如何了.唯一差别c++还是G++,但正解是后缀数组 ...
- 转载:字符串hash总结(hash是一门优雅的暴力!)
转载自:远航休息栈 字符串Hash总结 Hash是什么意思呢?某度翻译告诉我们: hash 英[hæʃ] 美[hæʃ]n. 剁碎的食物; #号; 蔬菜肉丁;vt. 把…弄乱; 切碎; 反复推敲; 搞糟 ...
- HDU 2089 不要62 | 暴力(其实是个DP)
题目: http://acm.hdu.edu.cn/showproblem.php?pid=2089 题解: 暴力水过 #include<cstdio> #include<algor ...
随机推荐
- android中使用哪种方式解析XML比較好
SAX是一个用于处理XML事件驱动的"推"模型. 长处是一种解析速度快而且占用内存少的xml解析器,它须要哪些数据再载入和解析哪些内容. 缺点是它不会记录标签的关系.而要让你的应用 ...
- Live555 实战之框架简单介绍
作者:咕唧咕唧liukun321 来自:http://blog.csdn.net/liukun321 上一篇文章简要介绍了怎样以共享库的方式交叉编译Live555,今天再来介绍live源代码框架. 先 ...
- 全响应跨设备的Zoomla!逐浪CMS2 x2.0正式公布
2014年是中国互联网的重要一年,京东上市.聚美优品领衔创业风范,小米进军国际化.滴滴快的锋火争雄. 作为中国互联网的中间力量,Zoomla!逐浪软件团队坚守信念,始终以WEB开发和科研创新为己任,并 ...
- POJ 1322 Chocolate
Chocolate Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 8245 Accepted: 2186 Speci ...
- C++11 lambda 表达式
C++11 新增了很多特性,lambda 表达式是其中之一,如果你想了解的 C++11 完整特性,建议去这里,这里,这里,还有这里看看.本文作为 5 月的最后一篇博客,将介绍 C++11 的 lamb ...
- Android服务Service总结
转自 http://blog.csdn.net/liuhe688/article/details/6874378 富貴必從勤苦得,男兒須讀五車書.唐.杜甫<柏學士茅屋> 作为程序员的我们, ...
- 【Solr初探】Solr安装,启动,查询,索引
1. 安装&启动 官网:http://lucene.apache.org/solr/ 下载源代码,解压,进入根目录(我把solr放在/usr/local/solr下) 在/usr/local/ ...
- 华为oj - 统计大写字母个数
练手而已. 给初学者参考 #include <stdio.h> #include <string.h> int main(void) { char string[200]={' ...
- C#中Byte转换相关的函数
1.将一个对象转换为byte对象 public static byte GetByte(object o) { ; if (o != null) { byte tmp; if (byte.TryPar ...
- jade中mixin的使用
h2 mixin mixin lesson p jade study +lesson mixin study(name,courses) p #{name} ul.courses each cours ...