Codeforces--400A--Inna and Choose Options(模拟水题)
Inna and Choose Options
Crawling in process...
Crawling failed
Time Limit:1000MS
Memory Limit:262144KB
64bit IO Format:%I64d & %I64u
Description
There always is something to choose from! And now, instead of "Noughts and Crosses", Inna choose a very unusual upgrade of this game. The rules of the game are given below:
There is one person playing the game. Before the beginning of the game he puts 12 cards in a row on the table. Each card contains a character: "X" or "O". Then the player chooses
two positive integers a and
b(a·b = 12), after that he makes a table of size
a × b from the cards he put on the table as follows: the first
b cards form the first row of the table, the second
b cards form the second row of the table and so on, the last
b cards form the last (number
a) row of the table. The player wins if some column of the table contain characters "X" on all cards. Otherwise, the player loses.
Inna has already put 12 cards on the table in a row. But unfortunately, she doesn't know what numbers
a and b to choose. Help her win the game: print to her all the possible ways of numbers
a, b that she can choose and win.
Input
The first line of the input contains integer t(1 ≤ t ≤ 100). This value shows the number of sets of test data in the input. Next follows the description of each of the
t tests on a separate line.
The description of each test is a string consisting of 12 characters, each character is either "X", or "O". The
i-th character of the string shows the character that is written on the
i-th card from the start.
Output
For each test, print the answer to the test on a single line. The first number in the line must represent the number of distinct ways to choose the pair
a, b. Next, print on this line the pairs in the format
axb. Print the pairs in the order of increasing first parameter (a). Separate the pairs in the line by
whitespaces.
Sample Input
4
OXXXOXOOXOOX
OXOXOXOXOXOX
XXXXXXXXXXXX
OOOOOOOOOOOO
3 1x12 2x6 4x3
4 1x12 2x6 3x4 6x2
6 1x12 2x6 3x4 4x3 6x2 12x1
0
将12张卡片分成矩阵,如果矩阵中有一列全都是X就输出这种排列方式,输出方式看样例,这里要注意输出的是x是小写的,还有对应关系,因为这还wa了两次
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
char str[15];
int vis[15];
memset(vis,0,sizeof(vis));
memset(str,'\0',sizeof(str));
cin>>str;
int ans=0,cnt=0;
for(int i=0;i<12;i++)
if(str[i]=='X')
cnt++;
if(cnt==0)
cout<<0<<endl;
else
{
vis[0]=1;
ans++; int f=false;
for(int i=0;i<6;i++)//2*6
if(str[i]=='X'&&str[i+6]=='X')
f=true;
if(f)
vis[1]=1,ans++; f=false;
for(int i=0;i<3;i++)//4*3
if(str[i]=='X'&&str[i+3]=='X'&&str[i+6]=='X'&&str[i+9]=='X')
f=true;
if(f)
vis[2]=1,ans++; f=false;
for(int i=0;i<4;i++)//3*4
if(str[i]=='X'&&str[i+4]=='X'&&str[i+8]=='X')
f=true;
if(f)
vis[3]=1,ans++; f=false;
for(int i=0;i<2;i++)//6*2
if(str[i]=='X'&&str[i+2]=='X'&&str[i+4]=='X'&&str[i+6]=='X'&&str[i+8]=='X'&&str[i+10]=='X')
f=true;
if(f)
vis[4]=1,ans++;
if(cnt==12) ans++;
printf("%d",ans);
if(vis[0]) printf(" 1x12");
if(vis[1]) printf(" 2x6");
if(vis[3]) printf(" 3x4");
if(vis[2]) printf(" 4x3");
if(vis[4]) printf(" 6x2");
if(cnt==12) printf(" 12x1");
printf("\n");
}
}
return 0;
}
Codeforces--400A--Inna and Choose Options(模拟水题)的更多相关文章
- CodeForces 400A Inna and Choose Options
Inna and Choose Options Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on Cod ...
- Codeforces Round #234 (Div. 2) A. Inna and Choose Options 模拟题
A. Inna and Choose Options time limit per test 1 second memory limit per test 256 megabytes input st ...
- CodeForces 689A Mike and Cellphone (模拟+水题)
Mike and Cellphone 题目链接: http://acm.hust.edu.cn/vjudge/contest/121333#problem/E Description While sw ...
- Codeforces Round #234 (Div. 2) :A. Inna and Choose Options
A. Inna and Choose Options time limit per test 1 second memory limit per test 256 megabytes input st ...
- Codeforces Round #234 (Div. 2) A. Inna and Choose Options
A. Inna and Choose Options time limit per test 1 second memory limit per test 256 megabytes input st ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- POJ 2014:Flow Layout 模拟水题
Flow Layout Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3091 Accepted: 2148 Descr ...
- codeforces Gym 100187L L. Ministry of Truth 水题
L. Ministry of Truth Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100187/p ...
- Codeforces Round #185 (Div. 2) B. Archer 水题
B. Archer Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/312/problem/B D ...
随机推荐
- CLISTCTRL2
回顾: 刚刚写完,因为是分期写的,所以最初想好好做一下的文章格式半途而废了~说的也许会有点啰嗦,但是所有的基础用到的技术细节应该都用到了. 如果还有什么疑问,请回复留言,我会尽力解答. 如果有错误,请 ...
- 日常开发需要掌握的Git命令
本人待的两家公司,一直都是用的SVN,Git我只是自己私下学习和开发小项目的时候用过,工作一直没有使用过,但还是要学的... Git是最好的分布式版本控制系统 工作流程 SVN和Git的区别 SVN是 ...
- ThinkPHP---TP功能类之邮件
[一]概论 (1)简介: 这里说的邮件不是平时说的email邮件(邮件地址带有@符号的),而是指的一般论坛网站的站内信息,也叫私信或者pm(private message私信) [二]站内信案例 (1 ...
- HDU5834 Magic boy Bi Luo with his excited tree (树形DP)
题意:一棵树有点权和边权 从每个点出发 走过一条边要花费边权同时可以获得点权 边走几次就算几次花费 点权最多算一次 问每个点能获得的最大价值 题解:好吧 这才叫树形DP入门题 dp[i][0]表示从i ...
- 1054.求平均数-PAT乙级真题
从其他博客优秀代码中学到了些技巧,记录一下. 思路:使用sscanf和sprintf函数. sscanf() – 从一个字符串中读进与指定格式相符的数据 sprintf() – 字符串格式化命令,主要 ...
- Jmeter逻辑控制器-ForEach Controller
ForEach Controller 介绍 ForEach Contoller 即循环控制器,顾名思义是定义一个规则.主要有以下一个参数: 名称:随便填写 注释:随便填写 输入变量前缀:可以在&quo ...
- mac下Redis安装和使用
前言 本篇文章主要讲述了Mac下Redis的安装和使用的经验,并将python如何操作Redis做了简单介绍. 1. redis 安装 和启动 1.1 用brew安装 查看系统是否已经安装了Redis ...
- 线程 synchronized锁机制
脏读 一个常见的概念.在多线程中,难免会出现在多个线程中对同一个对象的实例变量进行并发访问的情况,如果不做正确的同步处理,那么产生的后果就是"脏读",也就是取到的数据其实是被更改过 ...
- MongoDB 数据文件备份与恢复
备份与恢复数据对于管理任何数据存储系统来说都是非常重要的. 1.冷备份与恢复——创建数据文件的副本(前提是要停止MongoDB服务器),也就是直接copy MongoDB将所有数据都存储在数据目录下, ...
- Linux - 模块编程初试
计算机网络的课程设计要做防火墙,老师没有限制在什么系统上面做,所以决定在Linux上实现.找了一下相关的资料,发现其实Linux有提供Netfilter/Iptables,为用户提供防火墙的功能,稍微 ...