码迷,mamicode.com
首页 > 其他好文 > 详细

POJ 1430

时间:2014-10-12 14:12:28      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:blog   http   io   os   div   2014   log   amp   ef   

bubuko.com,布布扣

上面的估计是题解吧。。。。呃,如果真要用到公式的话,确实没听过。。。。

#include <iostream>
#include <cstdio>
#include <algorithm>
#define LL __int64

LL work(LL n){
	LL res=0; LL divd=2;
	while(divd<=n){
		res+=(n/divd);
		divd=(divd<<1);
	//	cout<<divd<<endl;
	}
	return res; 
}

int main(){
	LL n,k;
	int T;
	scanf("%d",&T);
	while(T--){
		scanf("%I64d%I64d",&n,&k);
		LL z=n-(LL)((k+2)/2);
		LL w=(k-1)/2;
		if(work(z)-work(w)-work(z-w)==0)
		printf("1\n");
		else printf("0\n");
	}
	return 0;
}

  

POJ 1430

标签:blog   http   io   os   div   2014   log   amp   ef   

原文地址:http://www.cnblogs.com/jie-dcai/p/4020313.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!