70pts求助!TLE->#12#15~18#20!
查看原帖
70pts求助!TLE->#12#15~18#20!
889828
Wangbingxiang楼主2024/10/25 12:17
#include<bits/stdc++.h>
using namespace std;
long long n,m;
long long read(){
	long long r=0;
	char ch[100001];
	scanf("%s",&ch);
	for(long long i=0;i<strlen(ch);i++){
		r*=10;
		r+=ch[i]-'0';
	}
	return r;
}
long long ksm(long long a,long long b){
	long long cnt=1;
	while(b){
		if(b%2){
			cnt*=a;
		}
		a*=a;
		b/=2;
	}
	return cnt;
}
int main(){
	n=read();m=read();
	n=ksm(2,n);
	bool flag=true;
	m+=1;
	while(n!=1){
		if(m>n) m-=n;
		if(flag){
			if(n/2<m){
				cout<<1;
				flag=false;
			}else{
				cout<<0;
			}
		}else if(!flag){
			if(n/2<m){
				cout<<0;
			}else{
				cout<<1;
				flag=true;
			} 
		}
		n/=2;
	}
	return 0;
}

2024/10/25 12:17
加载中...