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\n" );
        else printf( "2\n" );
    }
    return 0;
}
View Code

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

posted on 2017-08-15 21:22  FriskyPuppy  阅读(401)  评论(0编辑  收藏  举报

导航