HDU - 1847 Good Luck in CET-4 Everybody!(sg函数,水题)
题目链接:点击查看
题目大意:给出n张牌,两个人轮流摸牌,每次只能摸2的幂次,问先手必胜还是必败
题目分析:简单sg打表题,先预处理出sg表,然后O(1)查询即可
#include<iostream>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cctype>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<sstream>
#define Pi acos(-1.0)
using namespace std;typedef long long LL;const int inf=0x3f3f3f3f;const int N=1e3+100; int n;int a[110];int sg[N];bool mex[N];void get_SG()
{sg[0]=0;for(int i=1;i<N;i++){memset(mex,false,sizeof(mex));for(int j=1;j<=n;j++){if(a[j]>i)break;mex[sg[i-a[j]]]=true;}for(int j=0;j<N;j++){if(!mex[j]){sg[i]=j;break;}}}
}void init()
{n=0;for(int i=1;i<=1000;i<<=1)a[++n]=i;get_SG();
}int main()
{
// freopen("input.txt","r",stdin);init();int n;while(scanf("%d",&n)!=EOF){if(sg[n])printf("Kiki\n");elseprintf("Cici\n");}return 0;
}
HDU - 1847 Good Luck in CET-4 Everybody!(sg函数,水题)相关推荐
- HDU 1847 Good Luck in CET-4 Everybody! (sg函数)
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- HDU 1847 Good Luck in CET-4 Everybody
题目链接:Problem - 1847 (hdu.edu.cn) Problem Description 大学英语四级考试就要来临了,你是不是在紧张的复习?也许紧张得连短学期的ACM都没工 ...
- HDU 1847 Good Luck in CET-4 Everybody!(巴什博弈论)
题目地址:HDU 1847 这题可以用NP状态转换. 首先0的时候就代表无法出牌了,所以是必败态.然后根据每一个可以一步到达必败态的是必胜态,不可以一步到达必败态的是必败态.可以推出状态转移方程,然后 ...
- HDU1847 Good Luck in CET-4 Everybody!【SG函数】
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Ja ...
- hdu1847-Good Luck in CET-4 Everybody! (博弈论 SG函数 找规律)
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- HDU 1847 Good Luck in CET-4 Everybody! (巴什博弈)
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- HDU 1847 Good Luck in CET-4 Everybody!(组合博弈)
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- HDU 1847 ——Good Luck in CET-4 Everybody!
Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- HDU 1847 Good Luck in CET-4 Everybody! 尼姆博弈
点击打开链接 Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/3 ...
- HDU(1847)Good Luck in CET-4 Everybody!
利用PN分析求解此题.递推下去会发现3和3的倍数都是P点. #include <iostream> #include <stdio.h> #include <string ...
最新文章
- KWrite 和 Kate 在 Linux 上的应用
- Thymeleaf 标准表达式语法详解
- 《剑指offer》第十三题(机器人的运动范围)
- 怎么把rmd改成html,在Rmd中的htmlTable - 转换为Word docx
- MySQL 数据类型讲解 和Java中所对应的数据类型讲解
- axure能做剪切蒙版吗_大理石结晶自己能做吗?
- snprintf()返回值的陷阱
- js 打印出来的节点多了m_前端实用技术分享—用Vue实现打印指定区域
- Linux valgrind java_Ubuntu下使用valgrind所遇问题
- 基于FPGA的QAM调制
- 国内使用bing国际版(非国内国际切换版本)
- ubuntu 安装GPU黑屏 修改GRUB_Windows 10 amp; Ubuntu 18.04LTS双系统安装
- 商务英语计算机,怎样练习商务英语口语
- python输入个人所得税计算_python实例个税计算
- driver: linux下如何模拟按键输入和模拟鼠标
- Python生成标签云/词云
- PCB常用端子/排线
- 思绪——关于《朝花夕誓——于离别之朝束起约定之花》
- 基于SqlServer的DML(数据查询)实验,掌握select查询语句的使用、掌握有无条件查询、结果排序与分组、掌握视图用法
- X4扭曲字体或图形 coreldraw_CorelDRAW X4下载