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;
    }
    

      

  • 相关阅读:
    自定义协议的注册及程序示例转载
    在windows phone 中使用原生代码开发程序(native code)
    C# 操作系统防火墙转载
    WP7Windows Phone的Isolated Storage Explorer使用指南
    如何让wp7真机调试时候保持屏幕高亮不锁屏
    利用C#检测证书是否存在,并安装证书
    WPF设置附加属性的值
    wpf值转换器IValueConverter转载
    ADO.NET一些内幕
    怎样将数据库中所有表中含有numeric(18,2)字段改成numeric(18,10)及将float改成numeric
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5751367.html
Copyright © 2011-2022 走看看