import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int T=sc.nextInt();
for(int kase=0;kase<T;kase++){
BigInteger n = sc.nextBigInteger();
int m=sc.nextInt();
BigInteger two=BigInteger.valueOf(2);
BigInteger t =two.pow(m-1);
BigInteger sum = BigInteger.ZERO;
while(n.compareTo(BigInteger.ZERO)>0){
n = n.divide(t);
sum = sum.add(n).subtract(n.divide(two));
n = n.divide(two);
}
System.err.println(sum);
}
}
}
找规律hdu4577
最新推荐文章于 2017-05-15 10:14:23 发布