zoukankan      html  css  js  c++  java
  • HDU 6130 Kolakoski 思维个屁 水题

      题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=6130

      题目描述: 看呀看呀看题面, 找呀找呀找规律

      解题思路: 没啥好说的, 但是思考要好好写一下

      代码: 

    #include <iostream>
    #include <cstdio>
    #include <string>
    #include <vector>
    #include <cstring>
    #include <iterator>
    #include <cmath>
    #include <algorithm>
    #include <stack>
    #include <deque>
    #include <map>
    #define lson l, m, rt<<1
    #define rson m+1, r, rt<<1|1
    #define mem0(a) memset(a,0,sizeof(a))
    #define meminf(a) memset(a,0x3f,sizeof(a))
    typedef long long ll;
    using namespace std;
    
    const int maxn = 1e7+9;
    
    bool a[maxn];
    
    void solve() {
        a[1] = 0;
        a[2] = 1;
        a[3] = 1;
        int cnt = 3;
        int flag = 0;
        for( int i = 4; i <= maxn-4; ) {
            if( a[cnt] == 1 && !flag ) {
                a[i++] = 0;
                a[i++] = 0;
            }
            else if( a[cnt] == 0 && flag ) {
                a[i++] = 1;
            }
            else if( a[cnt] == 0  && !flag ) {
                a[i++] = 0;
            }
            else if( a[cnt] == 1 && flag ) {
                a[i++] = 1;
                a[i++] = 1;
            }
            cnt++;
            flag = !flag;
        }
    }
    
    int main() {
        solve();
        int t;
        scanf( "%d", &t );
        while( t-- ) {
            int n;
            scanf( "%d", &n );
            if( a[n] == 0 ) printf( "1
    " );
            else printf( "2
    " );
        }
        return 0;
    }
    View Code

      思考: 这题就是个大水题啊, 我一开始想当然了, 我以为题目给出那个序列个数的提示就是为了为了让你找规律, 找出循环节什么的, 仔细读题就会知道其实意思是这两个序列是一个序列!当时如果没有那么浮躁的话也不会找了半个小时规律结果发现1221121212...有个尼玛规律啊.......真的醉了, 以后读题一定要仔细, 每个地方都不能一眼带过

  • 相关阅读:
    Oracle OCP 11G 053(601-712)答案解析目录_20140304
    Oracle OCP 11G 053(201-400)答案解析目录_20140304
    Oracle OCP 11G 053(1-200)答案解析目录_20140304
    dojo实现表格数据无法展示
    dojo实现表格
    Matlab基本函数-menu函数
    Matlab基本函数-log10函数
    Matlab基本函数-log函数
    Matlab基本函数-length函数
    Matlab基本函数-imag函数
  • 原文地址:https://www.cnblogs.com/FriskyPuppy/p/7367832.html
Copyright © 2011-2022 走看看