POI 2000 ------Stripes
Stripes
|
Time Limit:1000MS Memory Limit:30000KB
Total Submit:94 Accepted:43
Description
Stripes is a two player game. Necessary requisites are a board and rectangular stripes in three colours: red, green and blue. All the red stripes have dimensions c x 1, green - z x 1, and blue - n x 1, where c, z and n are integers. Players have at their disposal an unlimited pool of stripes of each colour.
A game board is a rectangle of dimensions p x 1 and consists of p fields of size 1 x 1.
Players make their moves by turns. Move consists of laying a stripe of any colour on the board. There are the following rules in force:
A stripe cannot stick out of the board,
The covering (even partially) the earlier laid stripes is forbidden.
The ends of a stripe have to adhere to the edges of the fields on the board. The player, who is not able to perform his move in accordance to the game rules first, loses.
The first player is this one, who makes the first move in the game. It is said, that the first player has a winning strategy, if independently of the moves of the second player he can always win.
Task
Write a program, which:
1.reads sizes of stripes and of at least one board
2.for each board determines, whether the first player has a winning strategy,
3.writes the results.
Input
The first line of the input consists of three integers c, z and n, 1 <= c, z, n <= 1000, equal to the lengths of stripes, adequately: red, green and blue ones. Numbers in the line are separated by single spaces.
The second line of the file PAS.IN consists of one number m, 1 <= m <= 1000, which is equal to the number of different boards to consider. Lines from the 3-rd to the (m+2)-th consists of one number p, 1 <= p < 1000. Number in the (i+2)-th line is the length of the i-th board.
Output
The output should contain m lines. Only one number should be written in the i-th line of the file:
1 - if the first player has a winning strategy on the i-th board
2 - otherwise.
Sample Input
1 5 1
3
1
5
6
Sample Output
1
1
2
Source
一排石子有L个,甲乙两人轮流从中取“紧紧挨着的”A或B或C枚石子。
谁不能取了,谁就是输家。已知A, B, C, L,问甲乙二人谁有必胜策略。
http://acm.cs.ecnu.edu.cn/problem.php?problemid=1328
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std; bool use[];
int SG[];
void prepare(int a,int b,int c)
{
int i,j,k;
SG[]=;
for(i=;i<=;i++)
{
memset(use,false,sizeof(use));
for(j=;j<=i-a+;j++)
{
if(i-j-a+>=)
{
k=SG[j-]^SG[i-j-a+];
use[k]=true;
}
}
for(j=;j<=i-b+;j++)
{
if(i-j-b+>=)
{
k=SG[j-]^SG[i-j-b+];
use[k]=true;
}
}
for(j=;j<=i-c+;j++)
{
if(i-j-c+>=)
{
k=SG[j-]^SG[i-j-c+];
use[k]=true;
}
}
for(j=;;j++)
if(use[j]==false)
{
SG[i]=j;
break;
}
}
} int main()
{
int a,b,c;
int m,x;
while(scanf("%d%d%d",&a,&b,&c)>)
{
memset(SG,,sizeof(SG));
prepare(a,b,c);
scanf("%d",&m);
while(m--)
{
scanf("%d",&x);
if(SG[x]==)
printf("2\n");
else printf("1\n");
}
}
return ;
}
POI 2000 ------Stripes的更多相关文章
- 洛谷 P2444 [ POI 2000 ] 病毒 —— AC自动机+dfs
题目:https://www.luogu.org/problemnew/show/P2444 AC自动机上 dfs,不走结尾点,如果走出环就是有无限长度的串: RE无数,原来是数组开成 2000 的了 ...
- [POI 2000] 公共串
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2946 [算法] 建立多串后缀树 对于后缀树上的每个点 , 判断该节点所代表的等价类是 ...
- [POI 2000] 病毒
[题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2938 [算法] 首先建出给定字符串集的AC自动机 存在无限长的代码当且仅当 : AC ...
- POI操作Excel
POI和Excel简介 JAVA中操作Excel的有两种比较主流的工具包: JXL 和 POI .jxl 只能操作Excel 95, 97, 2000也即以.xls为后缀的excel.而poi可以操作 ...
- JAVA的POI操作Excel
1.1Excel简介 一个excel文件就是一个工作簿workbook,一个工作簿中可以创建多张工作表sheet,而一个工作表中包含多个单元格Cell,这些单元格都是由列(Column)行(Row)组 ...
- OAF_文件系列11_实现OAF读写Excel包JXL和POI的区别(概念)
20150803 Created By BaoXinjian
- 【POI word】使用POI实现对Word的读取以及生成
项目结构如下: 那第一部分:先是读取Word文档 package com.it.WordTest; import java.io.FileInputStream; import java.io.Fil ...
- java 使用 poi 解析excel
背景: web应用经常需要上传文件,有时候需要解析出excel中的数据,如果excel的格式没有问题,那就可以直接解析数据入库. 工具选择: 目前jxl和poi可以解析excel,jxl很早就停止维护 ...
- 021医疗项目-模块二:药品目录的导入导出-介绍poi类
我们使用的是.10版本 Apache POI - the Java API for Microsoft Documents,Apache POI 是用Java编写的免费开源的跨平台的 Java API ...
随机推荐
- jquery中的正则表达式
1.什么是正则表达式: 能让计算机读懂的字符串匹配规则. 2.正则表达式的写法: var re=new RegExp('规则', '可选参数');var re=/规则/修饰参数; 3.规则中的字符 1 ...
- java里面的标识符、关键字和类型
1. 注释 Java中有三种注释: (1) // -单行注释,注释从“//”开始,终止于行尾: (2) -多行注释,注释从““结束: (3) -是Java特有的doc注释,这种注释主 ...
- PyQt5(1)——Qt Designer初探
相关环境配置我们就不介绍了(网上有很多教程) Qt Designer 是一款十分强大的GUI工具,生成的文件为 .UI文件 可以通过命令转化为Py文件,简单来说我们可以通过拖拽方式生成界面,在通过简 ...
- 【BZOJ1296】[SCOI2009]粉刷匠 (DP+背包)
[SCOI2009]粉刷匠 题目描述 \(windy\)有 \(N\) 条木板需要被粉刷. 每条木板被分为 \(M\) 个格子. 每个格子要被刷成红色或蓝色. \(windy\)每次粉刷,只能选择一条 ...
- ubuntu16.04 能启动mysql服务
ubuntu16.04 后, 貌似mysqld在/etc/init.d下,直接执行会报mysqld不在服务中,因此开启mysql服务失败. 所以执行以下命令不能启动mysql服务: /etc/init ...
- springcloud(二)-最简单的实战
技术储备 Spring cloud并不是面向零基础开发人员,它有一定的学习曲线. 语言基础:spring cloud是一个基于Java语言的工具套件,所以学习它需要一定的Java基础.当然,sprin ...
- squid的简单介绍
squid的简单介绍 squid的概念 squid是一种用来缓存Internet数据的软件.接受来自人们需要下载的目标(object)的请求并适当的处理这些请求.也就是说,如果一个人想下载一web界面 ...
- [转] Vagrant入门
[From] https://www.cnblogs.com/davenkin/p/vagrant-virtualbox.html 简单地说,Vagrant让我们可以通过代码的方式快速地.可重复地创建 ...
- 怎么搭建vue-cli脚手架
我们在使用vue搭建项目的时候,经常要使用到vue-cli. 一.安装node.js 去node官网下载并安装node,一直next就行. 等待安装完毕,输入node-v,如果输出版本号,那说明已经成 ...
- day1-Python擅长的领域+学习内容
Python擅长的领域 WEB开发 Django Pyramid Tornado Bottle Flask WebPy 网络编程 Twisted Re ...