302103: CF400A. Inna and Choose Options

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Inna and Choose Options

题目描述

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 $ a $ x $ b $ . Print the pairs in the order of increasing first parameter ( $ a $ ). Separate the pairs in the line by whitespaces.

输入输出样例

输入样例 #1

4
OXXXOXOOXOOX
OXOXOXOXOXOX
XXXXXXXXXXXX
OOOOOOOOOOOO

输出样例 #1

3 1x12 2x6 4x3
4 1x12 2x6 3x4 6x2
6 1x12 2x6 3x4 4x3 6x2 12x1
0

Input

题意翻译

Inna 在玩井字棋的升级版。游戏规则如下: 在游戏开始前,他将 $12$ 张卡片排列在桌子上。每张卡片上都有一个字符 `X` 或 `O`。然后玩家选择两个正整数 $a$ 和 $b$ $(a\times b=12)$ ,然后根据放在桌子上的卡片制作一个 $a\times b$ 大小的表格,前 $b$ 张卡片组成第一行,接下来的 $b$ 张卡片组成第二行,依此类推,最后的 $b$ 张卡片组成最后一行(第 $a$ 行)。玩家获胜的条件是表格中某一列的所有卡片都含有字符 `X`。否则,玩家失败。 Inna 已经把 $12$ 张卡片按顺序放在了桌子上。但不幸的是,她不知道选择什么样的 $a$ 和 $b$ 来帮助她赢得游戏,所以她让你输出可能的所有选择 $a,b$,以及能够获胜的方式。 #### 输入格式 输入的第一行包含整数 $t$$(1\le t\le100) $。这个值表示输入中测试数据的个数。接下来的几行描述了每个测试的情况。 每个测试的描述都是一个由 $12$ 个字符组成的字符串,其中每个字符要么是 `X`,要么是 `O`。字符串的第 $i$ 个字符表示从开头算起第 $i$ 张卡片上的字符。 #### 输出格式 对于每个测试,将其答案打印在一行上。行中的第一个数字表示选择两个数 $ a,b $ 的不同方式的数量。接下来,在这一行上按照 $a$ 递增的顺序打印出这些对 $a,b$ 的选择。以 `a x b ` 的格式打印这些对。在行中用空格分隔这些对。 Translate by @[ZeXic_B](https://www.luogu.com.cn/user/661274)

加入题单

上一题 下一题 算法标签: