从昨天周赛开始,要耍CF了~

开始还害怕个人赛自己数论压根不会怎么办,发现CF全是乱搞的题orz

但是就算是乱搞的也不能1A  T^T

犯的错误基本上都是没有把情况归类导致要么是情况想少了,要么是细节处理的不好==

虽说不是算法题,质量还是不错的 贴下代码~·

1.

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 × bfrom 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<cstdio>
#include<cstring>
using namespace std;
int t;
char str[13];
int main()
{
   // freopen("cin.txt","r",stdin);
    scanf("%d",&t);
    getchar();
    while(t--)
    {
        scanf("%s",str);
        bool flag1=false,flag2=false;//1~Oexist   1~Xexist
        for(int i=0;i<12;i++)
        {
            if(str[i]=='O') flag2=true;//说明不全是X

            if(str[i]=='X') flag1=true;//说明不全是O
        }
            bool exist[10];
            int num=0;
            memset(exist,0,sizeof(exist));
            if(flag1==true) {exist[1]=true;num++;}
            if((str[0]==str[6]&&str[0]=='X')||(str[1]==str[7]&&str[1]=='X')||(str[2]==str[8]&&str[2]=='X')||(str[3]==str[9]&&str[3]=='X')||(str[4]==str[10]&&str[4]=='X')||(str[5]==str[11]&&str[5]=='X'))
               {
                   exist[2]=1;num++;
               }
            for(int i=0;i<4;i++)
            {
                if(str[i]==str[i+4]&&str[i]==str[i+8]&&str[i]=='X')
                {
                    exist[3]=1;num++;
                    break;
                }
            }
            for(int i=0;i<3;i++)
            {
                if(str[i]==str[i+3]&&str[i]==str[i+6]&&str[i]==str[i+9]&&str[i]=='X')
                {
                    exist[4]=1;
                    num++;
                    break;
                }
            }
            for(int i=0;i<2;i++)
            {
                if(str[i]==str[i+2]&&str[i]==str[i+4]&&str[i]==str[i+6]&&str[i]==str[i+8]&&str[i]==str[i+10]&&str[i]=='X')
                {
                    exist[5]=1;
                    num++;
                    break;
                }
            }
            if(flag1==true&&flag2==false){exist[6]=1;num++;}
            printf("%d",num);
            //if(num==0) {printf("\n");continue;}
            for(int i=1;i<=6;i++)
            {
                if(exist[i])
                switch(i)
                {
                    case 1:printf(" 1x12");break;
                    case 2:printf(" 2x6");break;
                    case 3:printf(" 3x4");break;
                    case 4:printf(" 4x3");break;
                    case 5:printf(" 6x2");break;
                    case 6:printf(" 12x1");break;
                }
            }
            printf("\n");
        }

    return 0;
}
2.这个题是说一直向右串,最多有多少个 G能遇到S

Description

Inna likes sweets and a game called the "Candy Matrix". Today, she came up with the new game "Candy Matrix 2: Reload".

The field for the new game is a rectangle table of size n × m. Each line of the table contains one cell with a dwarf figurine, one cell with a candy, the other cells of the line are empty. The game lasts for several moves. During each move the player should choose all lines of the matrix where dwarf is not on the cell with candy and shout "Let's go!". After that, all the dwarves from the chosen lines start to simultaneously move to the right. During each second, each dwarf goes to the adjacent cell that is located to the right of its current cell. The movement continues until one of the following events occurs:

  • some dwarf in one of the chosen lines is located in the rightmost cell of his row;
  • some dwarf in the chosen lines is located in the cell with the candy.

The point of the game is to transport all the dwarves to the candy cells.

Inna is fabulous, as she came up with such an interesting game. But what about you? Your task is to play this game optimally well. Specifically, you should say by the given game field what minimum number of moves the player needs to reach the goal of the game.

Input

The first line of the input contains two integers n and m(1 ≤ n ≤ 1000; 2 ≤ m ≤ 1000).

Next n lines each contain m characters — the game field for the "Candy Martix 2: Reload". Character "*" represents an empty cell of the field, character "G" represents a dwarf and character "S" represents a candy. The matrix doesn't contain other characters. It is guaranteed that each line contains exactly one character "G" and one character "S".

Output

In a single line print a single integer — either the minimum number of moves needed to achieve the aim of the game, or -1, if the aim cannot be achieved on the given game field.

Sample Input

Input
3 4
*G*S
G**S
*G*S
Output
2
Input
1 3
S*G
Output
-1
#include <iostream>
#include<cstring>
#include<cstdio>
using namespace std;
char str[1010][1010];
int n,m,num;
bool exist[1010];
bool mark;
int main()
{
    //freopen("cin.txt","r",stdin);
   // freopen("cout.txt","w",stdout);
    cin>>n>>m;
      // getchar();
        for(int i=0;i<n;i++)
            for(int j=0;j<m;j++)
                cin>>str[i][j];
        memset(exist,0,sizeof(exist));
        for(int i=0;i<n;i++)
        {
            mark=0;
            
            for(int j=0;j<m;j++)
            {
                int tmp;
                if(str[i][j]=='G'){
                    mark=1;
                    tmp=j;
                }
                if(str[i][j]=='S'&&mark==0){
                    cout<<"-1";
                    return 0;
                }
                if(str[i][j]=='S'&&mark==1)
                {
                    exist[j-tmp]=1;
                    //mark=0;
                }
            }
        }
        num=0;
        for(int i=0;i<m;i++)
        {
            if(exist[i]) num++;
        }
        cout<<num<<endl;

    return 0;
}

3.这个题简直错的奇葩!两个地方写错了没看出来 长宽不是输入一次x,y就就着上次的变一次啊 都是从原始值开始改变的啊;还有一个更奇葩的 z%=4写成了z%=4!能不能细心点!

Description

Inna and Dima decided to surprise Sereja. They brought a really huge candy matrix, it's big even for Sereja! Let's number the rows of the giant matrix from 1 to n from top to bottom and the columns — from 1 to m, from left to right. We'll represent the cell on the intersection of the i-th row and j-th column as (i, j). Just as is expected, some cells of the giant candy matrix contain candies. Overall the matrix has p candies: the k-th candy is at cell (xk, yk).

The time moved closer to dinner and Inna was already going to eat p of her favourite sweets from the matrix, when suddenly Sereja (for the reason he didn't share with anyone) rotated the matrix x times clockwise by 90 degrees. Then he performed the horizontal rotate of the matrix y times. And then he rotated the matrix z times counterclockwise by 90 degrees. The figure below shows how the rotates of the matrix looks like.

<center> </center>

Inna got really upset, but Duma suddenly understood two things: the candies didn't get damaged and he remembered which cells contained Inna's favourite sweets before Sereja's strange actions. Help guys to find the new coordinates in the candy matrix after the transformation Sereja made!

Input

The first line of the input contains fix integers nmxyzp(1 ≤ n, m ≤ 109; 0 ≤ x, y, z ≤ 109; 1 ≤ p ≤ 105).

Each of the following p lines contains two integers xkyk(1 ≤ xk ≤ n; 1 ≤ yk ≤ m) — the initial coordinates of the k-th candy. Two candies can lie on the same cell.

Output

For each of the p candies, print on a single line its space-separated new coordinates.

Sample Input

Input
3 3 3 1 1 9
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
Output
1 3
1 2
1 1
2 3
2 2
2 1
3 3
3 2
3 1
#include <iostream>
#include<cstdio>
using namespace std;
int n,m,x,y,z,p,h,w;
int i,j;
int main()
{
   // freopen("cin.txt","r",stdin);
    scanf("%d%d%d%d%d%d",&n,&m,&x,&y,&z,&p);
    x%=4;
    y%=2;
    z%=4;
  // printf("%d %d %d\n",x,y,z);
    while(p--)
    {
        h=n,w=m;
        scanf("%d%d",&i,&j);
        if(x&1)
        {
            int tmp=w;
            w=h;
            h=tmp;
        }
        if(x==1){int tmp=i;i=j;j=w+1-tmp;}
        else if(x==2){i=h+1-i;j=w+1-j;}
        else if(x==3){int tmp=j;j=i;i=h+1-tmp;}
        if(y==1){j=w+1-j;}
        //printf("%d %d ",i,j);
        //printf("h=%d w=%d ",h,w);
        if(z&1)
        {
            int tmp=w;
            w=h;
            h=tmp;
        }
      // printf("h=%d w=%d ",h,w);
        if(z==1){int tmp=j;j=i;i=h+1-tmp;}
        else if(z==2){i=h+1-i;j=w+1-j;}
        else if(z==3){int tmp=i;i=j;j=w+1-tmp;}
        printf("%d %d\n",i,j);
    }
    //printf("h=%d w=%d ",h,w);
    return 0;
}