hdu 4577 X-Boxes 大数
java水过……
代码如下:
import java.math.*;
import java.util.*;
public class Main {
public static void main(String arg[]){
BigInteger n,ans,sum;
Scanner cin = new Scanner(System.in);
int k,t=cin.nextInt();
while(t-->0){
n=cin.nextBigInteger();
k=cin.nextInt();
ans=BigInteger.ZERO;
while(true){
n=n.divide(BigInteger.valueOf(1<<(k-1)));
sum=n.subtract(n.divide(BigInteger.valueOf(2)));
if(sum.equals(BigInteger.ZERO)) break;
ans=ans.add(sum);
n=n.divide(BigInteger.valueOf(2));
}
System.out.println(ans);
}
}
}
hdu 4577 X-Boxes 大数的更多相关文章
- HDU 5047 Sawtooth(大数优化+递推公式)
http://acm.hdu.edu.cn/showproblem.php?pid=5047 题目大意: 给n条样子像“m”的折线,求它们能把二维平面分成的面最多是多少. 解题思路: 我们发现直线1条 ...
- Buy the Ticket HDU 1133 递推+大数
题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=1133 题目大意: 有m+n个人去买电影票,每张电影票50元, m个人是只有50元一张的, n个人 ...
- Children’s Queue HDU 1297 递推+大数
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=1297 题目大意: 有n个同学, 站成一排, 要求 女生最少是两个站在一起, 问有多少种排列方式. 题 ...
- HDU 6225 Little Boxes
Little Boxes Little boxes on the hillside. Little boxes made of ticky-tacky. Little boxes. Little ...
- HDU 5666 Segment 数论+大数
题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5666 bc(中文):http://bestcoder.hdu.edu.cn/contests ...
- HDU 4577 X-Boxes
X-Boxes Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total Sub ...
- HDU 1018Big Number(大数的阶乘的位数,利用公式)
传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1018 Big Number Time Limit: 2000/1000 MS (Java/Others) ...
- hdu 4068 I-number【大数】
题目: http://acm.hdu.edu.cn/showproblem.php?pid=4608 http://acm.hust.edu.cn/vjudge/contest/view.action ...
- HDU 1223 打表 + 大数
http://acm.hdu.edu.cn/showproblem.php?pid=1223 一般遇到这些题,我都是暴力输出前几项,找规律.未果. 然后输出n = 1时候,以A开始,有多少个答案, n ...
随机推荐
- linux umount 提示device is busy 的解决
linux umount 提示"device is busy" 终极解决 为了干净地关闭或热交换 UNIX 或类 UNIX 系统上的存储硬件,必须能够卸载使用此设备上的存储的所有文件系统.但是,如果正 ...
- iOS常用的设计模式
iOS常用的设计模式有:单例模式.委托模式.观察者模式和MVC模式.下面分别简单介绍. 一:单例模式 我们常用的UIApplication.NSUserdefaults.NSNotificationC ...
- ios 微信细节
1.登录后,下次登录保存其用户名. * 官方的登录实现 * 1.把用户名和密码放在沙盒 NSString *user = self.userField.text; NSStri ...
- 慕课网上的Bootstrap学习(二)
表单 首先<form role="form" class="form-horizontal"></form> ,创建一个水平显示的表单. ...
- AngularJS(7)-表格
ng-repeat 指令可以完美的显示表格. <!DOCTYPE html> <html lang="en"> <head> <meta ...
- JavaScript 防止事件冒泡
在我们书写一个弹窗的时候,我们往往需要点击弹窗的其他地方来隐藏弹窗. 通常我们会写成: $(document).bind('click',function(){ $('.pop-box').hide( ...
- Android:启动引导页实现
前言 基本上现在所有的应用都会有一个欢迎界面,在欢迎界面对应用做一个整体的介绍,然后在跳入到主界面,这次要说的这个引导页就是带翻页的引导页.效果如下所示
- PHP实现冒泡算法
<?php //php函数:count($arr)返回array的数值总数. function bubble_sort($arr){ for ($i = 6;$i > 0;$i --){ ...
- EditorLineEnds.ttr 受影响的D版本 Delphi 8-2010
http://stackoverflow.com/questions/25295980/delphi-2006-2010-error-cannot-create-file-c-users-admin- ...
- Spark Streaming揭秘 Day29 深入理解Spark2.x中的Structured Streaming
Spark Streaming揭秘 Day29 深入理解Spark2.x中的Structured Streaming 在Spark2.x中,Spark Streaming获得了比较全面的升级,称为St ...