• HDU


    题意:由1,2,2,1,1,2,1,2,2,1,2,2,1,1,2,1,1,2,2,1,……合并可得1,22,11,2,1,22,1,22,11,2,11,22,1,再由每个数的位数可得新序列,推出新序列第n项。

    分析:新序列与原序列相同,按题意打表即可。

    #include<cstdio>
    #include<cstring>
    #include<cstdlib>
    #include<cctype>
    #include<cmath>
    #include<iostream>
    #include<sstream>
    #include<iterator>
    #include<algorithm>
    #include<string>
    #include<vector>
    #include<set>
    #include<map>
    #include<stack>
    #include<deque>
    #include<queue>
    #include<list>
    #define lowbit(x) (x & (-x))
    const double eps = 1e-8;
    inline int dcmp(double a, double b){
        if(fabs(a - b) < eps) return 0;
        return a > b ? 1 : -1;
    }
    typedef long long LL;
    typedef unsigned long long ULL;
    const int INT_INF = 0x3f3f3f3f;
    const int INT_M_INF = 0x7f7f7f7f;
    const LL LL_INF = 0x3f3f3f3f3f3f3f3f;
    const LL LL_M_INF = 0x7f7f7f7f7f7f7f7f;
    const int dr[] = {0, 0, -1, 1, -1, -1, 1, 1};
    const int dc[] = {-1, 1, 0, 0, -1, 1, -1, 1};
    const int MOD = 1e9 + 7;
    const double pi = acos(-1.0);
    const int MAXN = 10000 + 10;
    const int MAXT = 10000 + 10;
    using namespace std;
    vector<int> v;
    int main(){
        v.push_back(1);
        v.push_back(2);
        v.push_back(2);
        v.push_back(1);
        v.push_back(1);
        int cur = 3;
        while(1){
            int cnt = v[cur];
            int x;
            if(v.size() & 1){
                x = 2;
            }
            else{
                x = 1;
            }
            for(int i = 0; i < cnt; ++i){
                v.push_back(x);
            }
            if(v.size() > 10000000) break;
        }
        int T;
        scanf("%d", &T);
        while(T--){
            int n;
            scanf("%d", &n);
            printf("%d
    ", v[n - 1]);
        }
        return 0;
    }
    

     

  • 相关阅读:
    Less资源汇总
    Less函数说明
    Less使用说明
    Less 简介
    tomcat-users.xml 配置
    java project打包生成jar包(通用)
    5分钟理解String的'+'的性能及原理
    字符串"+"操作的原理
    Shell脚本实现对文件编辑
    mysql关于聚集索引、非聚集索引的总结
  • 原文地址:https://www.cnblogs.com/tyty-Somnuspoppy/p/7367818.html
Copyright © 2020-2023  润新知