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

POI 2000 I Stage

一排石子有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的更多相关文章

  1. 洛谷 P2444 [ POI 2000 ] 病毒 —— AC自动机+dfs

    题目:https://www.luogu.org/problemnew/show/P2444 AC自动机上 dfs,不走结尾点,如果走出环就是有无限长度的串: RE无数,原来是数组开成 2000 的了 ...

  2. [POI 2000] 公共串

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2946 [算法] 建立多串后缀树 对于后缀树上的每个点 , 判断该节点所代表的等价类是 ...

  3. [POI 2000] 病毒

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=2938 [算法] 首先建出给定字符串集的AC自动机 存在无限长的代码当且仅当 : AC ...

  4. POI操作Excel

    POI和Excel简介 JAVA中操作Excel的有两种比较主流的工具包: JXL 和 POI .jxl 只能操作Excel 95, 97, 2000也即以.xls为后缀的excel.而poi可以操作 ...

  5. JAVA的POI操作Excel

    1.1Excel简介 一个excel文件就是一个工作簿workbook,一个工作簿中可以创建多张工作表sheet,而一个工作表中包含多个单元格Cell,这些单元格都是由列(Column)行(Row)组 ...

  6. OAF_文件系列11_实现OAF读写Excel包JXL和POI的区别(概念)

    20150803 Created By BaoXinjian

  7. 【POI word】使用POI实现对Word的读取以及生成

    项目结构如下: 那第一部分:先是读取Word文档 package com.it.WordTest; import java.io.FileInputStream; import java.io.Fil ...

  8. java 使用 poi 解析excel

    背景: web应用经常需要上传文件,有时候需要解析出excel中的数据,如果excel的格式没有问题,那就可以直接解析数据入库. 工具选择: 目前jxl和poi可以解析excel,jxl很早就停止维护 ...

  9. 021医疗项目-模块二:药品目录的导入导出-介绍poi类

    我们使用的是.10版本 Apache POI - the Java API for Microsoft Documents,Apache POI 是用Java编写的免费开源的跨平台的 Java API ...

随机推荐

  1. [转] HTTP状态码错误代码

    一些常见的状态码为: 200 - 服务器成功返回网页 404 - 请求的网页不存在 503 - 服务不可用 详细分解: 1xx(临时响应) 表示临时响应并需要请求者继续执行操作的状态代码. 代码 说明 ...

  2. ubuntu14.04搭建ftp服务器

    一,搭建匿名FTP服务器 实现ftp匿名登录,上传,下载,重命名文件. 1. 首先安装vsftpd:sudo apt-get install vsftpd,装好之后,默认的ftp根目录是在 /srv/ ...

  3. Postman使用手册2——管理收藏

    一.开始使用收藏夹 收藏夹会使你的工作效率更上一层楼 收藏夹可以让单个的request分组在一起,这些request可以被进一步的管理到文件夹来更准确的反应你的API.request也可以在保存到收藏 ...

  4. UIImageView笔记

    image的伸缩变换 最好是image和imageview的size一致.如果不一致,最终的效果由imageView的contentMode和image的属性共同决定. 如果image没有cap in ...

  5. Maven依赖的JAR包下载慢?赶紧看过来

    相信许多JAVA开发者在日常工作中时常会碰到这种情况,那就是编译Maven工程时,工程所依赖的jar包文件下载非常慢,甚至经常出现下载不成功的问题,今天,小编就给大家讲讲如何提升Maven依赖包的下载 ...

  6. Angular material mat-icon 资源参考_Places

    ul,li>ol { margin-bottom: 0 } dt { font-weight: 700 } dd { margin: 0 1.5em 1.5em } img { height: ...

  7. js高级程序设计 笔记 --- 表单

    一,基础知识 在html中,表单是form元素,而在js中,表单对应的是HTMLFormElement类型,继承自HTMLElement,其独特的属性和方法有(常见): action:接收请求的URL ...

  8. [转] scala中:: , +:, :+, :::, +++的区别

    [From] https://segmentfault.com/a/1190000005083578 初学scala的人都会被Seq的各种操作符所confuse.下面简单列举一下各个Seq操作符的区别 ...

  9. Flutter 实现退出登录功能,应用退出到登录界面 | 返回应用首页

    1. 使用场景:退出登录./// 路由作用:移除 [ModalRoute.withName("/loginPage")] 除外的所有界面,并跳转到 ["/loginPag ...

  10. appium关于当前网络情况测试,实现打开关闭网络(python3.4版)

    appium关于当前网络情况测试,实现打开关闭网络(不需要root测试机) # python from appium.webdriver.connectiontype import Connectio ...