对称构造

Alice and Bob decide to play a funny game. At the beginning of the game they pick n(1 <= n <= 10 6) coins in a circle, as Figure 1 shows. A move consists in removing one or two adjacent coins, leaving all other coins untouched. At least one coin must be removed. Players alternate moves with Alice starting. The player that removes the last coin wins. (The last player to move wins. If you can‘t move, you lose.)

Figure 1

Note: For n > 3, we use c1, c2, ..., cn to denote the
coins clockwise and if Alice remove c2, then c1 and c3 are NOT adjacent!
(Because there is an empty place between c1 and c3.)

Suppose that both Alice and Bob do their best in the game.

You are to write a program to determine who will finally win the game.

Input

There are several test cases. Each test case has only one line, which contains a positive integer n (1 <= n <= 10
6). There are no blank lines between cases. A line with a single 0 terminates the input.

Output

For each test case, if Alice win the game,output "Alice", otherwise output "Bob".

Sample Input

1
2
3
0

Sample Output

Alice
Alice
Bob

列几项出来,能看见好东西
#include<stdio.h>

int main()
{
    int n;
    while(scanf("%d",&n)&&n!=0)
    {
        if(n==1||n==2)
            printf("Alice\n");
        else
            printf("Bob\n");
    }
    return 0;
}
时间: 2024-10-08 02:08:31

对称构造的相关文章

HDU 5355 Cake (WA后AC代码,具体解析,构造题)

题目链接:http://acm.hdu.edu.cn/showproblem.php? pid=5355 题面: Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1632    Accepted Submission(s): 273 Special Judge Problem Description There are s

HDU 5355 Cake (WA后AC代码,详细解析,构造题)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5355 题面: Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 1632    Accepted Submission(s): 273 Special Judge Problem Description There are m

URAL 1614. National Project “Trams” (图论大YY)

1614. National Project "Trams" Time limit: 0.5 second Memory limit: 64 MB President has declared the development of tram service a priority national project. As a part of this project, Yekaterinburg will receive enough budget funds to carry out

Codeforces 12E Start of the season 构造 一个n*n矩阵使得每行恰好有一个[0,n-1]且对称

题目链接:点击打开链接 题意: 给定一个n 构造 一个n*n矩阵使得每行恰好有一个[0,n-1]且关于主对角线对称 且主对角线必须全为0 #include<stdio.h> #include<iostream> #include<string.h> #include<set> #include<vector> #include<map> #include<math.h> #include<queue> #inc

构造树并判断是否对称

class Node { constructor (val) { this.val = val this.left = this.right = undefined } } class Tree { constructor (data) { // 临时存储所有节点 let nodeList = [] // 根节点 let root for (let i = 0, len = data.length; i < len; i++) { let node = new Node(data[i]) nod

AES —— JAVA中对称加密和解密

package demo.security; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Base64; impor

codeforces #550D Regular Bridge 构造

题目大意:给定k(1≤k≤100),要求构造一张简单无向连通图,使得存在一个桥,且每一个点的度数都为k k为偶数时无解 证明: 将这个图缩边双,能够得到一棵树 那么一定存在一个叶节点,仅仅连接一条桥边 那么这个边双内部全部点度数之和为偶数 除掉连出去的桥边外度数之和为奇数 故不合法 然后k为奇数的时候我们仅仅须要构造两个对称的边双被一条桥边连接的图即可了 因为每一个点度数为k.因此每一边至少须要k+1个点 可是k+1个点奇偶性不合法.因此每一边至少须要k+2个点 如今问题转化成了给定一个度数数组

JAVA中AES对称加密和解密

AES对称加密和解密 package demo.security; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SecureRandom; import java.util.Ba

BZOJ 1982: [Spoj 2021]Moving Pebbles [博弈论 对称]

给你N堆Stone,两个人玩游戏. 每次任选一堆,首先拿掉至少一个石头,然后移动任意个石子到任意堆中. 谁不能移动了,谁就输了... 以前在poj做过已经忘记了... 构造对称,选最多的一堆往其他堆分构造对称局面,先手必胜 一开始就对称,先手必败 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using