zoukankan      html  css  js  c++  java
  • Good morning! Gym

    #include<map>
    #include<queue>
    #include<time.h>
    #include<limits.h>
    #include<cmath>
    #include<ostream>
    #include<iterator>
    #include<set>
    #include<stack>
    #include<cstdio>
    #include<cstring>
    #include<iostream>
    #include<algorithm>
    using namespace std;
    #define rep_1(i,m,n) for(int i=m;i<=n;i++)
    #define mem(st) memset(st,0,sizeof st)
    #define int long long
    typedef long long ll;
    typedef pair<int,int> pii;
    typedef unsigned long long ull;
    typedef pair<double,double> pdd;
    const int maxn = 1e9;
    #define x first
    #define y second
    pair<int,int>pos[15];
    int num[210];
    int cnt=0;
    bool check(int x)
    {
    	bool f1=1;
    	int z=x%10;
    	while(x)//傻逼边界 
    	{
    		//只能出现在右下 
    		if (pos[z].x>=pos[x%10].x && pos[z].y>=pos[x%10].y)
    		{
    			z=x%10;
    			x/=10;
    		}
    		else 
    			return 0;
    	}
    	return f1;
    }
    void init()
    {
    	pos[1]= {1,1};
    	pos[2]= {1,2};
    	pos[3]= {1,3};
    	pos[4]= {2,1};
    	pos[5]= {2,2};
    	pos[6]= {2,3};
    	pos[7]= {3,1};
    	pos[8]= {3,2};
    	pos[9]= {3,3};
    	pos[0]= {4,2};
    	num[0]=0;
    	for(int i=0; i<=200; i++)
    		if(check(i))
    			num[++cnt]=i;
    }
    void solve()
    {
    	int n;
    	cin>>n;
    	int t=1;
    	while(num[t]<=n && t<=cnt)
    		t ++;
    	if(num[t]-n>n-num[t-1])
    		t--;
    	cout<<num[t]<<endl;
    		
    }
    signed main()
    {
    	int t;
    	cin>>t;
    	init();
    	while(t--)
    		solve();
    	return 0;
    }
    
  • 相关阅读:
    EMC研究院电面记
    被百度放了鸽子
    最长严格递增子序列算法
    括号配对问题
    RTP 协议
    C++ 纯虚函数, 记上一笔!
    一年又一年
    direct3d Colorkey 应用.
    CEGUI 中文输入与显示
    被遗忘的C,记录一笔
  • 原文地址:https://www.cnblogs.com/QingyuYYYYY/p/12867191.html
Copyright © 2011-2022 走看看