time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

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.

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 test(s)
Input
4
OXXXOXOOXOOX
OXOXOXOXOXOX
XXXXXXXXXXXX
OOOOOOOOOOOO
Output
3 1x12 2x6 4x3
4 1x12 2x6 3x4 6x2
6 1x12 2x6 3x4 4x3 6x2 12x1
0

给仅仅含‘X'和’O'字符的长度为12的字符串,将它写入矩阵a*b(a*b=12)中。问存在某一列全为‘X'的矩阵的个数。

用的万能的打表。

23333


#include<cstdio>
#include<iostream>
#include<cstring>
#include<queue>
#include<algorithm>
#include<vector> using namespace std; const int N = 20;
int n ;
char s[N];
char str[N][N];
int flag;
int ans; int tt(int a, int b)
{
int i, j;
for(i=0; i<a; i++)
for(j=0; j<b; j++)
{
str[i][j] = s[ i*b+j ];
}
for(i=0; i<b; i++)
{
for(j=0; j<a; j++)
{
if( str[j][i]!='X' )
break;
}
if(j==a)
return 1;
} return 0;
} int main()
{
scanf("%d", &n);
while( n-- )
{
ans = 0;
scanf("%s", &s);
if( tt(1, 12) )
ans++;
if( tt(2, 6) )
ans++;
if( tt(3, 4) )
ans++;
if( tt(4, 3) )
ans++;
if( tt(6, 2) )
ans++;
if( tt(12, 1) )
ans++; printf("%d", ans); if( tt(1, 12) )
printf(" 1x12");
if( tt(2, 6) )
printf(" 2x6");
if( tt(3, 4) )
printf(" 3x4");
if( tt(4, 3) )
printf(" 4x3");
if( tt(6, 2) )
printf(" 6x2");
if( tt(12, 1) )
printf(" 12x1"); printf("\n");
} return 0;
}

Codeforces Round #234 (Div. 2) :A. Inna and Choose Options的更多相关文章

  1. 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 ...

  2. 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 ...

  3. 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 ...

  4. Codeforces Round #234 (Div. 2)

    A. Inna and Choose Options time limit per test 1 second memory limit per test 256 megabytes input st ...

  5. 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 ...

  6. 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 ...

  7. Codeforces Round #482 (Div. 2) : Kuro and GCD and XOR and SUM (寻找最大异或值)

    题目链接:http://codeforces.com/contest/979/problem/D 参考大神博客:https://www.cnblogs.com/kickit/p/9046953.htm ...

  8. Codeforces Round #482 (Div. 2) :B - Treasure Hunt

    题目链接:http://codeforces.com/contest/979/problem/B 解题心得: 这个题题意就是三个人玩游戏,每个人都有一个相同长度的字符串,一共有n轮游戏,每一轮三个人必 ...

  9. Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)

    F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...

随机推荐

  1. ASP.NET MVC:三个被隐藏的扩展性“钻石”(转载)

    原文地址:http://haacked.com/archive/2010/05/16/three-hidden-extensibility-gems-in-asp-net-4.aspx/. ASP.N ...

  2. Oracle初级索引学习总结

    前言  索引是常见的数据库对象,建立索引的目的是为了提高记录的检索速度.它的设置好坏,使用是否得当,极大地影响数据库应用程序和Database的性能.虽然有许多资料讲索引的用法,DBA和Develop ...

  3. 64位Windows操作系统中的注冊表

    x64系统上有x64.x86两种注冊表,记录下. 64 位Windows系统中的注冊表分为 32 位注冊表项和 64 位注冊表项.很多 32 位注冊表项与其对应的 64 位注冊表项同名. 在64位版本 ...

  4. Javascrip获取页面URL信息

    使用Javascript可以方便获得页面的参数信息,常用的几种如下: 设置或获取对象指定的文件名或路径 window.location.pathname   设置或获取整个 URL 为字符串 wind ...

  5. Pandas 快速入门(二)

    本文的例子需要一些特殊设置,具体可以参考 Pandas快速入门(一) 数据清理和转换 我们在进行数据处理时,拿到的数据可能不符合我们的要求.有很多种情况,包括部分数据缺失,一些数据的格式不正确,一些数 ...

  6. Javascript 对象(object)合并

    对象的合并 需求:设有对象 o1 ,o2,需要得到对象 o3 var o1 = { a:'a' }, o2 = { b:'b' }; // 则 var o3 = { a:'a', b:'b' } 方法 ...

  7. SVG渲染顺序及z轴显示问题(zIndex)

    SVG是严格按照定义元素的顺序来渲染的,这个与HTML靠z-index值来控制分层不一样. 在SVG中,写在前面的元素先被渲染,写在后面的元素后被渲染.后渲染的元素会覆盖前面的元素,虽然有时候受透明度 ...

  8. 图像质量评估(IQA)

    图像质量评估函数的分类曾是一个比较有争议的话题,在2l世纪以前曾经有过 比较多的讨论.但是随着研究的深入和技术的广泛应用,研究人员对于图像质量 评估函数的分类有了统一的认识,即从实际应用中参考信息供给 ...

  9. Intelli系列代理部分报错:You have JVM property https.proxyHost set..

    You have JVM property https.proxyHost set to '...'. This may lead to incorrect behaviour. Proxy shou ...

  10. 指定文件兼容性模式 < meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />的意义

    X-UA-Compatible是神马? X-UA-Compatible是IE8的一个专有<meta>属性,它告诉IE8采用何种IE版本去渲染网页,在html的<head>标签中 ...