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 ...
随机推荐
- 【驱动】USB驱动实例·串口驱动·键盘驱动【转】
转自:http://www.cnblogs.com/lcw/p/3159370.html Preface USB体系支持多种类型的设备. 在 Linux内核,所有的USB设备都使用 usb_drive ...
- Python [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed 解决方法
一个搭建在SAE上的Django应用,使用新浪微博提供的Python SDK已经稳定运行一年有余,但最近开始持续出现微博认证失败的状况. 摘录微博python SDK的错误提示如下所示: ERROR: ...
- java基础35 双例集合Map及其常用方法
单例集合体系: ---------| collection 单例集合的根接口--------------| List 如果实现了list接口的集合类,具备的特点:有序,可重复 注:集合 ...
- JZOJ1517. 背包问题
这个题,乍一看感觉挺神的(其实真挺神的),其实是个简单的分组背包(如果恍然大悟就不用接着看了) 取连续的一段是这道题最难以处理的地方,但是观察到物品数量不多<=100(如果恍然大悟就不用接着看了 ...
- epoll对poll(select)的改进
select的几大缺点: 每次调用select,都需要把fd集合从用户态拷贝到内核态,这个开销在fd很多时会很大: 每次调用select,内核需要遍历传递进来的所有fd(判断检测文件是否可用).有 ...
- Shell学习笔记:#*、%*字符串掐头去尾方法
一.语法 在shell中可以通过#.%对字符串进行掐头去尾操作,使用方法如下: # 表示掐头 % 表示去尾 单个#或%表示最小匹配 双个$或%表示最大匹配 二.例子1 假设我们定义一个变量为: fi ...
- Oracle工作笔记
重命名表 RENAME PUB_ORDER_DATE_RES TO PUB_ORDER_DATA_RES; 新增字段 ); 删除字段 ALTER TABLE PUB_ORDER_DATA_RES DR ...
- 树莓派GPIO控制RGB彩色LED灯
树莓派GPIO通过PWM来控制RGB彩色LED灯,可以显示任何我们想要的颜色. RGB模块简介 这个RGB彩色LED里其实有3个灯,分别是红灯.绿灯和蓝灯.控制这三个灯分别发出不同强度的光,混合起来就 ...
- 使用EasyWechat快速开发微信公众号支付
前期准备: 申请微信支付后, 会收到2个参数, 商户id,和商户key.注意,这2个参数,不要和微信的参数混淆.微信参数: appid, appkey, token支付参数: merchant_id( ...
- Android Activity、Service、BroadcastReceiver 的生命周期
Activity.Service.BroadcastReceiver这三个组建是Android开发中最常使用到的组件,在它们的生命周期的各个阶段我们需要针对性的做些事情,了解这些组件的生命周期有利于我 ...