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

      

  • 相关阅读:
    QOS-Qos标记和QOS-Policy策略
    QOS-CBQ概述
    QOS-基本拥塞管理机制(PQ CQ WFQ RTPQ)
    QOS-QOS(服务质量)概述
    MariaDB数据库服务
    24、配置Oracle下sqlplus历史命令的回调功能
    11、nginx+tomcat+redis_session共享
    9、make和make install的区别
    10、nginx+uwsgi+django部署(动静分离)
    15、iptables_nat目标地址转换(外网访问内网)
  • 原文地址:https://www.cnblogs.com/zhangchengc919/p/5751367.html
Copyright © 2011-2022 走看看