ACM--模拟--Inna and Choose Options--水

题目地址:传送门

H - Inna and Choose Options

Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d
& %I64u

Submit Status

Description

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 Input

Input

4
OXXXOXOOXOOX
OXOXOXOXOXOX
XXXXXXXXXXXX
OOOOOOOOOOOO

Output

3 1x12 2x6 4x3
4 1x12 2x6 3x4 6x2
6 1x12 2x6 3x4 4x3 6x2 12x1
0
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main(){
   int n;
   string s;
   scanf("%d",&n);

   while(n--){
      cin>>s;

    int flag_1=0,flag_2=0,flag_3=0, result=1;
    int flag_4=0,i,flag_5=0,flag_6=1;
      //1*12
      for(i=0;i<12;i++){
         if(s[i]=='X'){
            flag_1=1;
            result++;
            break;
         }
      }
      //2*6
      for(i=0;i<6;i++){
          if(s[i]=='X'&&s[i+6]=='X'){
            flag_2=1;
            result++;
            break;
          }
      }
      //3*4
      for(i=0;i<4;i++){
          if(s[i]=='X'&&s[i+4]=='X'&&s[i+8]=='X'){
             flag_3=1;
             result++;
             break;
          }
      }
      //4*3
      for(i=0;i<3;i++){
         if(s[i]=='X'&&s[i+3]=='X'&&s[i+6]=='X'&&s[i+9]=='X'){
            flag_4=1;
            result++;
            break;
         }
      }
      //6*2
      for(i=0;i<2;i++){
          if(s[i]=='X'&&s[i+2]=='X'&&s[i+4]=='X'&&
             s[i+6]=='X'&&s[i+8]=='X'&&s[i+10]=='X'){
              flag_5=1;
              result++;
               break;
          }
      }
      //12*1
      for(i=0;i<12;i++){
         if(s[i]=='O'){
            flag_6=0;
            result--;
            break;
         }
      }
      printf("%d ",result);
      if(flag_1){
          printf("1x12 ");

      }
      if(flag_2){
          printf("2x6 ");

      }
      if(flag_3){
          printf("3x4 ");

      }
      if(flag_4){
          printf("4x3 ");

      }
      if(flag_5){
          printf("6x2 ");

      }
      if(flag_6){
          printf("12x1");

      }
      printf("\n");
   }
}
时间: 2024-10-27 07:58:50

ACM--模拟--Inna and Choose Options--水的相关文章

CodeForces 400A Inna and Choose Options

Inna and Choose Options Time Limit: 1000ms Memory Limit: 262144KB This problem will be judged on CodeForces. Original ID: 400A64-bit integer IO format: %I64d      Java class name: (Any) There always is something to choose from! And now, instead of "N

codeforces400A - Inna and Choose Options 暴力

题意:给你12张只包含X 和O的牌,问你n*m = 12 中,每一列都是X的情况有几种: 谁把这题定为DP题信不信我砍死你. 解题思路:我愚蠢的暴力 解题代码: 1 // File Name: 400a.cpp 2 // Author: darkdream 3 // Created Time: 2014年07月24日 星期四 08时48分04秒 4 5 #include<vector> 6 #include<list> 7 #include<map> 8 #includ

[ACM] Color the ball [线段树水题][数组开大]

Description N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的"小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色.但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗? Input 每个测试实例第一行为一个整数N,(N <= 100000).接下来的N行,每行包括2个整数a b(1 <= a <= b <= N).  当N

ACM: POJ 1401 Factorial-数论专题-水题

POJ 1401 Factorial Time Limit:1500MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Description The most important part of a GSM network is so called Base Transceiver Station (BTS). These transceivers form the areas called cells (this term

ACM :漫漫上学路 -DP -水题

CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit Status Description 对于csuxushu来说,能够在CSU(California State University)上学是他一生的荣幸.CSU校园内的道路设计的十分精巧,由n+1条水平道路和n+1条竖直道路等距交错而成,充分体现了校园深厚的文化底蕴.然而不幸的是CS市每到夏季,天降大雨,

acm hdu p2547 无剑无我{水水水}

无剑无我 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4112    Accepted Submission(s): 2638 Problem Description 北宋末年,奸臣当道,宦官掌权,外侮日亟,辽军再犯.时下战火连连,烽烟四起,哀鸿遍野,民不聊生,又有众多能人异士群起而反,天下志士云集响应,景粮影从. 值此危急存亡之秋

ACM: FZU 2110 Star - 数学几何 - 水题

FZU 2110  Star Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Practice Description Overpower often go to the playground with classmates. They play and chat on the playground. One day, there are a lot of stars in the sky.

HDU ACM 1039 Easier Done Than Said? 水题

分析:判断密码是否安全. 三个条件:至少一个元音字母,连续三个字母不能同时为元音或辅音,连续两个字母不能相同,但"ee"和"oo"除外. #include<iostream> using namespace std; bool isyuan(char c) { return c=='a' || c=='e' || c=='i' || c=='o' || c=='u'; } bool judge(char a[]) { int i,l; l=strlen(

HDU 3月ACM模拟赛T10 COUNT

题面 //来自TKJ的友好提供 ^_^ 然后我又被卡了半天不知道怎么转移N3 于是听CWY给我讲 终于会了 (虽然他讲的不是很清楚QAQ 但是凭着我们之间根本不存在的默契竟然达成了心智联通) 重点在于 怎么转移N3 —— > (N+1)3 (n+1)3 = n3 + 3n2+ 3n + 1 于是ans列是{f[i-2], --->f[i-1] f[i-1], --->f[i] i3, --->(i+1)3 i2, --->(i+1)2 i, ---i+1 1}; ---1 好