zoukankan      html  css  js  c++  java
  • Boring Game

    参考:https://blog.csdn.net/qq_45458915/article/details/107804348

    模拟题

    给出 n 张叠在一起的纸,现在将其连续从左向右折叠 k 次,再从上到下标上序号,问展开后的序号是怎么样的

    可以把展开看作一条纸带对折多次后形成的样子。

    未通过,写完还是OT

    附未通过代码

    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<algorithm>
    #include<bitset>
    #include<cassert>
    #include<cctype>
    #include<cmath>
    #include<cstdlib>
    #include<ctime>
    #include<deque>
    #include<iomanip>
    #include<list>
    #include<map>
    #include<queue>
    #include<set>
    #include<stack>
    #include<vector>
    #include <vector>
    #include <iterator>
    #include <utility>
    #include <sstream>
    #include <limits>
    #include <numeric>
    #include <functional>
    using namespace std;
    #define gc getchar()
    #define mem(a) memset(a,0,sizeof(a))
    //#define sort(a,n,int) sort(a,a+n,less<int>())
    
    #define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    
    typedef long long ll;
    typedef unsigned long long ull;
    typedef long double ld;
    typedef pair<int,int> pii;
    typedef char ch;
    typedef double db;
    
    const double PI=acos(-1.0);
    const double eps=1e-6;
    const int inf=0x3f3f3f3f;
    const int maxn=1e5+10;
    const int maxm=100+10;
    const int N=1e6+10;
    const int mod=1e9+7;
    
    vector<int> node[N];
    int main()
    {
    	int T = 0;
    	cin >> T;
    	while(T--)
    	{
    		int n , k , L;
    		cin >> n >> k;
    		L = n << (k+1);		
    		for(int i = 1;i <= L;i++)
    		{
    			node[i].clear();
                int x;	
    			cin >> x;
    			node[i].push_back(x); 
    		}
    		int mid = 1;
    		int p = 0;
    		for(int i = 1;i <= k;i++)
    		{
    			mid = (mid + L)/2;
    			for(int j = mid + 1;j <= L;j++)
                {
                    p = mid - (j - (mid+1)); 
                    reverse(node[p].begin() , node[p].end());
                    node[j].insert(node[j].begin() , node[p].begin() , node[p].end());
                    node[p].clear(); 
                }
    		}
    		for(int i = L-n*2+1;i <= L;i++)
    		{
    			for(int j = 0;j < node[i].size();j++)
    			{
    				if(j == node[i].size()-1  &&  i == L)
    				{
    					cout << node[i][j];
    				}
    				else
    				{
    					cout << node[i][j] <<" ";
    				}
    			}
    		 } 
    		 cout << endl;
    	}
    } 
    

      

  • 相关阅读:
    音频波谱通用类|超酷的说
    跟随鼠标的星星实例
    AS3放大镜工具类
    caurina缓动类
    AS3中 is,as,typeof的区别
    Loader ,URLLoader ,URLStream的区别
    (转)AS3正则:元子符,元序列,标志,数量表达符
    动态绘制扇形实例
    AS3.0绘图API
    as3效率优化
  • 原文地址:https://www.cnblogs.com/SutsuharaYuki/p/13460301.html
Copyright © 2011-2022 走看看