本文主要是介绍CF MemSQL Round1 E. The Red Button,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
题目:The Red Button
思路:YY
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <cstring>
using namespace std;
bool vis[100010];
int main()
{memset(vis,false,sizeof(vis));stack<int>s;while(!s.empty())s.pop();int n;scanf("%d",&n);if(n&1)printf("-1\n");else{int p=n/2;vis[p]=1;int tmp;while(p!=1){s.push(p);tmp=p+n;if(!vis[tmp/2])p=tmp/2;elsep/=2;vis[p]=1;//cout<<p<<endl;}s.push(1);s.push(0);while(!s.empty())cout<<s.top()<<" ",s.pop();cout<<0<<endl;}return 0;
}
这篇关于CF MemSQL Round1 E. The Red Button的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!