zoukankan      html  css  js  c++  java
  • codeforces 705B B. Spider Man(组合游戏)

    题目链接:

    B. Spider Man

    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    Peter Parker wants to play a game with Dr. Octopus. The game is about cycles. Cycle is a sequence of vertices, such that first one is connected with the second, second is connected with third and so on, while the last one is connected with the first one again. Cycle may consist of a single isolated vertex.

    Initially there are k cycles, i-th of them consisting of exactly vi vertices. Players play alternatively. Peter goes first. On each turn a player must choose a cycle with at least 2 vertices (for example, x vertices) among all available cycles and replace it by two cycles with p andx - p vertices where 1 ≤ p < x is chosen by the player. The player who cannot make a move loses the game (and his life!).

    Peter wants to test some configurations of initial cycle sets before he actually plays with Dr. Octopus. Initially he has an empty set. In thei-th test he adds a cycle with ai vertices to the set (this is actually a multiset because it can contain two or more identical cycles). After each test, Peter wants to know that if the players begin the game with the current set of cycles, who wins?

    Peter is pretty good at math, but now he asks you to help.

    Input

    The first line of the input contains a single integer n (1 ≤ n ≤ 100 000) — the number of tests Peter is about to make.

    The second line contains n space separated integers a1, a2, ..., an (1 ≤ ai ≤ 109), i-th of them stands for the number of vertices in the cycle added before the i-th test.

    Output

    Print the result of all tests in order they are performed. Print 1 if the player who moves first wins or 2 otherwise.

    Examples
    input
    3
    1 2 3
    output
    2
    1
    1
    input
    5
    1 1 5 1 1
    output
    2
    2
    2
    2
    2

    题意:

    每次能把一个至少两个点的环变成两个环,现在问是先手还是后手胜?

    思路:

    最后都变成了1,那就看都变成1要操作多少次,跟奇偶有关;

    AC代码:
    /************************************************
    ┆  ┏┓   ┏┓ ┆   
    ┆┏┛┻━━━┛┻┓ ┆
    ┆┃       ┃ ┆
    ┆┃   ━   ┃ ┆
    ┆┃ ┳┛ ┗┳ ┃ ┆
    ┆┃       ┃ ┆ 
    ┆┃   ┻   ┃ ┆
    ┆┗━┓    ┏━┛ ┆
    ┆  ┃    ┃  ┆      
    ┆  ┃    ┗━━━┓ ┆
    ┆  ┃  AC代马   ┣┓┆
    ┆  ┃           ┏┛┆
    ┆  ┗┓┓┏━┳┓┏┛ ┆
    ┆   ┃┫┫ ┃┫┫ ┆
    ┆   ┗┻┛ ┗┻┛ ┆      
    ************************************************ */ 
     
     
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <algorithm>
    #include <cmath>
    #include <bits/stdc++.h>
    #include <stack>
    #include <map>
     
    using namespace std;
     
    #define For(i,j,n) for(int i=j;i<=n;i++)
    #define mst(ss,b) memset(ss,b,sizeof(ss));
     
    typedef  long long LL;
     
    template<class T> void read(T&num) {
        char CH; bool F=false;
        for(CH=getchar();CH<'0'||CH>'9';F= CH=='-',CH=getchar());
        for(num=0;CH>='0'&&CH<='9';num=num*10+CH-'0',CH=getchar());
        F && (num=-num);
    }
    int stk[70], tp;
    template<class T> inline void print(T p) {
        if(!p) { puts("0"); return; }
        while(p) stk[++ tp] = p%10, p/=10;
        while(tp) putchar(stk[tp--] + '0');
        putchar('
    ');
    }
     
    const LL mod=1e9+7;
    const double PI=acos(-1.0);
    const LL inf=1e18;
    const int N=1e5+10;
    const int maxn=2e3+14;
    const double eps=1e-12;
    
    
    int a[N];
    int main()
    {
        int n;
        LL sum=0;
        read(n);
        For(i,1,n)
        {
            read(a[i]);
            sum=sum+a[i]-1;
            if(sum&1)printf("1
    ");
            else printf("2
    ");
        }
    
    
        return 0;
    }
    

      

  • 相关阅读:
    【IIS错误】IIS各种错误
    【IIS错误
    【C#】C#操作Excel文件(转)
    【C#】语音识别
    【IIS错误】未能加载文件或程序集“AAAAA”或它的某一个依赖项。试图加载格式不正确的程序。
    【Web前端】清除css、javascript及背景图在浏览器中的缓存
    【模态窗口-Modeldialog】提交请求时禁止在新窗口打开页面的处理方法
    第八周学习进度表
    梦断代码阅读笔记01
    第二阶段冲刺第七天
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5751367.html
Copyright © 2011-2022 走看看