这是怎么回事
查看原帖
这是怎么回事
359883
Grace25楼主2021/7/9 17:43

卡着时限过也算超时吗?

附上代码:

#include<iostream>
#include<cstring>
#include<cmath>
using namespace std;
int l,D,I,ans;
bool tree[530000];
void drop(int k){
	if(pow(2.0,float(D-1)) <= k && k < pow(2.0,float(D))){
		ans=k;
		return;
	}
	if(tree[k]) drop(2*k+1);
	else drop(2*k);
	tree[k]=!tree[k];
}
int main(){
	cin >> l;
	for(int i=1;i<=l;i++){
		memset(tree,false,sizeof(tree));
		cin >> D >> I;
		for(int j=1;j<=I;j++){
			drop(1);
		}
		cout << ans << endl;
	}
	return 0;
}

PS: 本人太弱,请大佬勿喷

2021/7/9 17:43
加载中...