UVA 1482 - Playing With Stones(SG打表规律)
来源:互联网 发布:手机股票交易软件 知乎 编辑:程序博客网 时间:2024/04/30 01:34
UVA 1482 - Playing With Stones
题目链接
题意:给定n堆石头,每次选一堆取至少一个,不超过一半的石子,最后不能取的输,问是否先手必胜
思路:数值很大,无法直接递推sg函数,打出前30项的sg函数找规律
代码:
#include <stdio.h>#include <string.h>int t, n;long long num;long long SG(long long x) {return x % 2 == 0 ? x : SG(x / 2);}int main() {scanf("%d", &t);while (t--) {scanf("%d", &n);long long ans = 0;for (int i = 0; i < n; i++) {scanf("%lld", &num);ans ^= SG(num); } printf("%s\n", ans == 0 ? "NO" : "YES"); }return 0;}
1 0
- UVA 1482 - Playing With Stones(SG打表规律)
- UVA-1482 Playing With Stones(SG函数打表找规律)
- UVA 1482 - Playing With Stones (SG博弈)
- UVA - 1482 Playing With Stones
- UVA1482:Playing With Stones(SG)
- uva 1482 - Playing With Stones(Nim游戏)
- UESTC 1661 Playing With Stones 博弈打表
- 【LA 5059】 Playing With Stones|博弈论|SG函数
- uvalive 5059 Playing With Stones(组合游戏,SG函数)@
- LA5059 Playing With Stones
- La 5059 - Playing With Stones
- Codeforces 768E Game of Stones 博弈SG(打表)
- UVALive 5059 C Playing With Stones
- hdu 4664 Triangulation(博弈论 sg找规律打表)
- UVa 10067 - Playing with Wheels
- UVALive/LA 5059 Play with Stones 组合游戏/SG定理
- UVALive 5059 Play with Stones SG函数,难度较低
- PC/UVa 110902/10067 Playing With Wheels
- 怎样理解分页作业是一维的,分段作业是二维的
- iphone开发笔记
- poj 3565 Ants 最小权匹配
- LeetCode2.1.17 @ Plus One 数组数字加一 D1F2
- windows下使用for 和perl命令批量修改多个文件内容
- UVA 1482 - Playing With Stones(SG打表规律)
- Android实现异步处理 -- HTTP请求为例
- swift不同类型 相加
- MYSQL 表中汉字写入或字段赋值时乱码情况排误
- MFC内部组织原理结构
- Windows下配置Ruby on Rails开发环境
- 支付宝的性能测试
- Qt学习笔记2014.7.16.13:33——菜单栏
- 一个菜鸟的营销路