Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

纯属瞎蒙

Posted by KatrineYang at 2016-12-03 04:51:07 on Problem 1430
//============================================================================
// Name        : 123.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <stdio.h>
#include <cstdlib>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <cstring>

using namespace std;

int getAns(int m, int n){
	if(m<=2) return 1;
	int k = 1;
	while(k < m) k*=2;
	k/=2;
	n = n%k;
	if(m%2!=0) m++;
	int aa = getAns(m/2, n/2);
	if(aa==0) return 0;
	if(m%4==0 && n%2==1) return 0;
	return 1;
}

int main() {
	int d;
	cin >> d;
	while(d--){
		int m,n;
		cin >> n >> m;
		if(n<m) cout << 0 << endl;
		else if(m==0&& n==0) cout << 1 << endl;
		else if(m==0 ||n==0) cout << 0 << endl;
		else{
			n = n-m;
			cout << getAns(m,n) << endl;
		}
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator