Sicily 1798. Alice and Bob
来源:互联网 发布:java工程师学什么专业 编辑:程序博客网 时间:2024/05/19 05:03
· 策略类问题,直接判断奇偶即可得出结果。
· 证明:1、当n为偶数时,棋盘可以被n * n / 2个 1*2骨牌覆盖,则Alice赢。使Alice走的第一个与起始点属于同一个骨牌,则接下来每当Bob走到一个新的骨牌上,Alice便走骨牌的另一个,即无论Bob怎么走,Alice都一定有路可走,最终Bob会将自己走死。 2、当n为基数时,n * n为基数,则除去起始点,剩下的格子可以被 (n * n - 1) / 2个1*2骨牌覆盖,则先在的情况变成了Alice总走骨牌的第一格,Bob走第二格,所以Bob赢。
代码如下:
#include <iostream>using namespace std; int main() { int n; while ( cin >> n && n ) { if ( (n * n) % 2 == 0 ) cout << "Alice" << endl; else cout << "Bob" << endl; } }
阅读全文
1 0
- Sicily 1798. Alice and Bob
- sicily--1798. Alice and Bob
- Sicily 1798. Alice and Bob
- Sicily 1798. Alice and Bob
- Sicily 1732. Alice and Bob
- Sicily 13289. Alice and Bob
- Sicily 2683. Alice and Bob
- 1798. Alice and Bob
- Sicily 1732 Alice and Bob (二进制数的最大公约数)
- sicily 1798.Aclie and Bob
- Alice and Bob
- 2683. Alice and Bob
- hdu4268 Alice and Bob
- HDU4268 Alice and Bob
- Alice, Bob and Chocolate
- hdu4268 Alice and Bob
- A:Alice and Bob
- hdu4111 Alice and Bob
- 2.1.5脏读(dirtyRead)
- Java基础学习之java基本语法(4)【数组】
- jsp简介
- 间接寻址--简单操作
- Java Activiti(6)--流程变量的添加与获取(表act_ru_variable)
- Sicily 1798. Alice and Bob
- 模糊控制简介及数学基础 (模糊集合、隶属函数)
- Ural 1003 Parity(并查集)
- leetcode.array--42. Trapping Rain Water
- 算法设计与分析(屈婉玲)网络课学习笔记(一)
- JavaScript是如何实现继承的(六种方式)
- HDU-4476 Cut the rope (枚举、前缀和)
- 前端考试知识点归纳总结
- IntelliJ IDEA+SpringBoot中静态资源访问路径陷阱:静态资源访问404