POJ 1430

上面的估计是题解吧。。。。呃,如果真要用到公式的话,确实没听过。。。。
#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的更多相关文章
- POJ 1430 Binary Stirling Numbers (第二类斯特林数、组合计数)
题目链接 http://poj.org/problem?id=1430 题解 qaq写了道水题-- 在模\(2\)意义下重写一下第二类Stirling数的递推式: \[S(n,m)=S(n-1,m-1 ...
- poj 1430 Binary Stirling Numbers
Binary Stirling Numbers Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 1761 Accepted ...
- poj 1430 第二类斯特林数
1 #include <iostream> #include <cmath> #include <algorithm> using namespace std; i ...
- poj 1430 Binary Stirling Number 求斯特林数奇偶性 数形结合| 斯特林数奇偶性与组合数的关系+lucas定理 好题
题目大意 求子集斯特林数\(\left\{\begin{matrix}n\\m\end{matrix}\right\}\%2\) 方法1 数形结合 推荐一篇超棒的博客by Sdchr 就是根据斯特林的 ...
- poj 题目分类(1)
poj 题目分类 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K--0.50K:中短代码:0.51K--1.00K:中等代码量:1.01K--2.00K:长代码:2.01 ...
- POJ题目分类(按初级\中级\高级等分类,有助于大家根据个人情况学习)
本文来自:http://www.cppblog.com/snowshine09/archive/2011/08/02/152272.spx 多版本的POJ分类 流传最广的一种分类: 初期: 一.基本算 ...
- POJ题目细究
acm之pku题目分类 对ACM有兴趣的同学们可以看看 DP: 1011 NTA 简单题 1013 Great Equipment 简单题 102 ...
- 转载:poj题目分类(侵删)
转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码) ...
- POJ 3370. Halloween treats 抽屉原理 / 鸽巢原理
Halloween treats Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 7644 Accepted: 2798 ...
随机推荐
- 洛谷—— P1238 走迷宫
https://www.luogu.org/problem/show?pid=1238 题目描述 有一个m*n格的迷宫(表示有m行.n列),其中有可走的也有不可走的,如果用1表示可以走,0表示不可以走 ...
- spring boot不同环境读取不同配置
具体做法: 不同环境的配置设置一个配置文件,例如:dev环境下的配置配置在application-dev.properties中:prod环境下的配置配置在application-prod.prope ...
- [Preference] How to avoid Forced Synchronous Layout or FSL to improve site preference
When tigger site updates the layout, it always follow this order: Javascript trigger style changes, ...
- 本地自旋锁与信号量/多服务台自旋队列-spin wait风格的信号量
周日傍晚,我去家附近的超市(...)买苏打水,准备自制青柠苏打.我感觉我做的比买的那个巴黎水要更爽口.由于天气太热,非常多人都去超市避暑去了,超市也不撵人,这仿佛是他们的策略.人过来避暑了,走的时候难 ...
- UVA 10593 Kites DP
The season of flying kites is well ahead. So what? Let us make an inventory for kites. We are givena ...
- How do I UPDATE from a SELECT in SQL Server?
方法1 https://stackoverflow.com/questions/2334712/how-do-i-update-from-a-select-in-sql-server UPDATE T ...
- java中的NIO
使用传统的输入输出流,当读取输入流中的数据如果没有没有读到有效的数据时,程序将在此处阻塞该线程的执行(使用InputStream的read方法从流中读取数据时,如果数据源中没有数据,它也会阻塞该线程) ...
- springMVC+uploadify3.1 文件上传 demo
uploadify3.1 api 可参考:(点击打开链接) 需要springmvc的jar包 1.upload.jsp(主要代码) <script type="text/javascr ...
- 3d touch 的使用(一)
废话不多说,直接上代码------------------ 在 - (BOOL)application:(UIApplication *)application didFinishLaunchingW ...
- 流式计算新贵Kafka Stream设计详解--转
原文地址:https://mp.weixin.qq.com/s?__biz=MzA5NzkxMzg1Nw==&mid=2653162822&idx=1&sn=8c4611436 ...