好的呢,TLE 4个点
查看原帖
好的呢,TLE 4个点
406170
Jason_yinkai楼主2021/8/7 15:08

这是测试点

#include<iostream>
#include<queue>
using namespace std;
int k;
bool check(int x){
	queue<int> q;
	for(int i = 1;i <= k;i++){
		q.push(1);
	}
	for(int j = 1;j <= k;j++){
		q.push(0);
	}
	while(!q.empty()){
		for(int j = 1;j < x;j++){
			int now = q.front();
			q.pop();
			q.push(now);
		}
		if(q.front() == 1 and q.size() > k) return false;
		else q.pop();
	}
	return true;
}
void f(){
	for(int i = 1;;i++){
		if(check(i)){
			cout<<i;
			break;
		}
	}
	
}
int main(){
	cin>>k;
    f();
}
2021/8/7 15:08
加载中...