首页 > 代码库 > poj 1430 第二类斯特林数

poj 1430 第二类斯特林数



 1 #include <iostream>
 2 #include <cmath>
 3 #include <algorithm>
 4 using namespace std;
 5 
 6 int get2(long long n){
 7     if(n==0)
 8         return 0;
 9     int cnt =0;
10     while(n){
11         cnt += n/2;
12         n = n/2;
13     }
14     return cnt;
15 }
16 int main(){
17 
18     int t;
19     cin>>t;
20     long long n,m;
21     while(t--){
22         cin>>n>>m;
23         long long z = n-(m+2)/2;
24         long long w = (m-1)/2;
25         if(get2(z)-get2(w)-get2(z-w)>0){
26             cout<<0<<endl;
27         }else{
28             cout<<1<<endl;
29         }
30     }
31     return 0;
32 }