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
给仅仅含‘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的更多相关文章
- 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) 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 ...
- 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 #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 #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 ...
- Codeforces Round #482 (Div. 2) :B - Treasure Hunt
题目链接:http://codeforces.com/contest/979/problem/B 解题心得: 这个题题意就是三个人玩游戏,每个人都有一个相同长度的字符串,一共有n轮游戏,每一轮三个人必 ...
- Codeforces Round #532 (Div. 2):F. Ivan and Burgers(贪心+异或基)
F. Ivan and Burgers 题目链接:https://codeforces.com/contest/1100/problem/F 题意: 给出n个数,然后有多个询问,每次回答询问所给出的区 ...
随机推荐
- 基于Memcached的tomcat集群session共享所用的jar
多个tomcat各种序列化策略配置如下:一.java默认序列化tomcat配置conf/context.xml添加<Manager className="de.javakaffee.w ...
- 摩拜单车模式优于OFO双向通信才能被认可
马化腾 :摩拜单车模式优于OFO双向通信才能被认可 2017-06-20 00:12 最近共享单车里最头条的新闻是 悟空单车宣布退出竞争,并全部退还投资款和押金以及余额.运营才5个月,成为第一家倒下的 ...
- Asp.Net Mvc控制器重名问题整理
一.关于控制器重名问题 1.没有区域的时候控制器不能重名 2.有区域的时候,外部控制器和区域中的控制器重名,访问外部控制器异常,访问区域控制器正常. 3.区域和区域之间的控制器重名,互不影响.区域从某 ...
- IIS7增加mine类型,以便可以访问apk
1.打开IIS 2.找到mine类型,单击右边的添加 3.输入apk的配置 application/vnd.android-package-archive .这样,用户就可以直接访问apk了
- float,double等精度丢失问题 float,double内存表示
问题提出:12.0f-11.9f=0.10000038,"减不尽"为什么? 来自MSDN的解释: http://msdn.microsoft.com/zh-cn/c151dt3s. ...
- 【已解决】unity4.2.0f4 导出Android工程报错:Error building Player: ArgumentException: Illegal characters in path. [unity导出android工程 报错,路径含有非法字符]
使用unity3D开发的一个客户端,需要导出为Android工程,然后接入一些第三方android SDK. unity版本 操作系统为: OS 名称: Microsoft Windows 7 旗舰版 ...
- Guava中针对集合的 filter和过滤功能
在guava库中,自带了过滤器(filter)的功能,可以用来对collection 进行过滤,先看例子: import com.google.common.base.Predicates; impo ...
- Sutherland-Hodgeman多边形裁剪
原文地址:http://course.cug.edu.cn/cugFirst/computer_graphics/class/course/3-3-1-a.htm
- DLL文件实现窗体的模板模式
机房合作版中第一次使用了模板方法,实现了类似窗体的界面和代码的复用..窗体继承有两种方法,一种是通过继承选择器从已编译的程序集合里选择,另一种则是通过DLL文件的方式继承.个人觉得DLL还是比较方便的 ...
- 构建-14 Gradle使用技巧
官方文档 Gradle 提示与诀窍 [Gradle tips and recipes] Gradle 和 Android Plugin for Gradle 提供了一种灵活的方式[a flexible ...