Codeforces Round #234 (Div. 2) A. Inna and Choose Options 模拟题
1 second
256 megabytes
standard input
standard output
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.
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.
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.
4
OXXXOXOOXOOX
OXOXOXOXOXOX
XXXXXXXXXXXX
OOOOOOOOOOOO
3 1x12 2x6 4x3
4 1x12 2x6 3x4 6x2
6 1x12 2x6 3x4 4x3 6x2 12x1
0
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
int main()
{
int t;
cin>>t;
string s;
while(t--)
{
cin>>s;
int ans=;
int flag[];
memset(flag,,sizeof(flag));
for(int i=;i<;i++)
{
if(s[i]=='X')
{
ans++;
flag[]=;
break;
}
}
for(int i=;i<;i++)
{
if(s[i]=='X'&&s[i+]=='X')
{
ans++;
flag[]=;
break;
}
}
for(int i=;i<;i++)
{
if(s[i]=='X'&&s[i+]=='X'&&s[i+]=='X')
{
ans++;
flag[]=;
break;
}
}
for(int i=;i<;i++)
{
if(s[i]=='X'&&s[i+]=='X'&&s[i+]=='X'&&s[i+]=='X')
{
ans++;
flag[]=;
break;
}
}
for(int i=;i<;i++)
{
if(s[i]=='X'&&s[i+]=='X'&&s[i+]=='X'&&s[i+]=='X'&&s[i+]=='X'&&s[i+]=='X')
{
ans++;
flag[]=;
break;
}
}
ans++;
flag[]++;
for(int i=;i<;i++)
{
if(s[i]=='O')
{
ans--;
flag[]--;
break;
}
}
cout<<ans;
//6 1x12 2x6 3x4 4x3 6x2 12x1
if(flag[]==)
cout<<" "<<"1x12";
if(flag[]==)
cout<<" "<<"2x6";
if(flag[]==)
cout<<" "<<"3x4";
if(flag[]==)
cout<<" "<<"4x3";
if(flag[]==)
cout<<" "<<"6x2";
if(flag[]==)
cout<<" "<<"12x1";
cout<<endl;
}
return ;
}
Codeforces Round #234 (Div. 2) A. Inna and Choose Options 模拟题的更多相关文章
- 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) B. Inna and New Matrix of Candies
B. Inna and New Matrix of Candies time limit per test 1 second memory limit per test 256 megabytes i ...
- Codeforces Round #234 (Div. 2) B. Inna and New Matrix of Candies SET的妙用
B. Inna and New Matrix of Candies time limit per test 1 second memory limit per test 256 megabytes i ...
- Codeforces Round #375 (Div. 2) Polycarp at the Radio 优先队列模拟题 + 贪心
http://codeforces.com/contest/723/problem/C 题目是给出一个序列 a[i]表示第i个歌曲是第a[i]个人演唱,现在选出前m个人,记b[j]表示第j个人演唱歌曲 ...
- 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 time limit per test 1 second memory limit per test 256 megabytes input st ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos (水题)
Brain's Photos 题目链接: http://codeforces.com/contest/707/problem/A Description Small, but very brave, ...
- Codeforces Round #281 (Div. 2) A. Vasya and Football 模拟
A. Vasya and Football 题目连接: http://codeforces.com/contest/493/problem/A Description Vasya has starte ...
- Codeforces Round #234 (Div. 2):B. Inna and New Matrix of Candies
B. Inna and New Matrix of Candies time limit per test 1 second memory limit per test 256 megabytes i ...
随机推荐
- JAVA_OPTS讲解【转】
JAVA_OPTS ,顾名思义,是用来设置JVM相关运行参数的变量. JAVA_OPTS="-server -Xms256m -Xmx512m -XX:PermSize=64M -XX:Ma ...
- Python 使用 Redis 操作
1.redis简介 redis是一款开源免费的高性能key-value数据库,redis特点: 支持更多的数据类型:字符串(String).列表(List).哈希(Map).数字(Int).集合(Se ...
- 查看sql语句加锁信息
问题: 最近使用quartz集群,总是报deadlock问题,所以需要查看一下执行的sql导致的加锁冲突. 步骤: 1.在要测试的库中创建指定表innodb_lock_monitor create t ...
- 使用脚本实现killproc的功能
在shell提示符号下输入type killproc,会发现killproc实在 /sbin/目录下,通过man killproc可以查看这个脚本(姑且这么称为脚本)的用法,现在,把这个脚本的实现过程 ...
- java基础27 单例集合Collection及其常用方法
1.集合 集合是存储对象数据的集合容器 1.1.集合比数组的优势 1.集合可以存储任意类型的数据,数组只能存储同一种数据类型的数据 2.集合的长度是变化的,数组的长度是固定的 1.2.数组:存储 ...
- Git push将本地版本库的分支推送到远程服务器上对应的分支
在使用git commit命令将修改从暂存区提交到本地版本库后,只剩下最后一步将本地版本库的分支推送到远程服务器上对应的分支了,如果不清楚版本库的构成,可以查看我的另一篇,git 仓库的基本结构. g ...
- CNN细节
1.各层作用 输入层 输入层是整个神经网络的输入,一般代表的是图片的像素矩阵(一般为三维矩阵,即像素x像素x通道) 卷积层 每一层卷积都会提取数据特征,再经过组合和抽象形成更高阶的特征. 池化层 保留 ...
- AARRR:数据运营模型
一.基础知识 产品经理 <增长黑客>数据分析基础 -- 获取(Acquisition)-- 激活(Activation)-- 留存(Retention)-- 收入(Revenue)-- ...
- Asp.net MVC4 +EF6开发的个人网站源码和介绍(仅供新手学习)
本项目是我去年利用业余时间开发的,采用的是asp.net mvc 4 +EF6+三层架构,适合新手进行学习,高手就没有什么价值了,可以直接跳过. 源码和数据库下载(已上传到git):https://g ...
- 【51nod】1709 复杂度分析
题解 考虑朴素的暴力,相当于枚举u点的每个祖先f,然后统计一下这个点f除了某个儿子里有u的那个子树之外的节点个数,乘上f到u距离的二进制1的个数 那么我们用倍增来实现这个东西,每次枚举二进制的最高位j ...