[Cpp]
Description: dizzy. It is always wrong Because gets is used to read the string, but it is correct to read it with scanf. It is speechless. There is a string. The length of the string len represents a matrix of len * len ,? This indicates that a queen can be placed in a row of people in this column. The Queen can only attack one column and target the places around it. numbers and letters are hexadecimal and are represented by n, indicates that there must be a queen in row n of this column. That is to say, this column has been determined to only have this queen.
# Include <cstdio>
# Include <cstring>
# Include <cstdlib>
Long v [20] [20];
Int main ()
{
// Freopen ("a.txt", "r", stdin );
Int len;
Int arr [20];
Char s [50];
Long sum;
While (scanf ("% s", s )! = EOF)
{
Len = strlen (s );
For (int I = 0; I <len; I ++)
If (s [I] = '? ') Arr [I + 1] = 0;
Else if (s [I]> = '1' & s [I] <= '9') arr [I + 1] = s [I]-'0 ';
Else if (s [I]> = 'A' & s [I] <= 'F ') arr [I + 1] = s [I]-'A' + 10;
Memset (v, 0, sizeof (v ));
If (! Arr [1]) for (int I = 1; I <= len; I ++) v [I] [1] = 1;
Else v [arr [1] [1] = 1;
For (int I = 2; I <= len; I ++)
If (! Arr [I])
{
For (int j = 1; j <= len; j ++)
For (int k = 1; k <= len; k ++)
If (abs (k-j)> 1) v [j] [I] + = v [k] [I-1];
}
Else
{
For (int k = 1; k <= len; k ++)
If (abs (k-arr [I])> 1) v [arr [I] [I] + = v [k] [I-1];
}
Sum = 0;
For (int I = 1; I <= len; I ++) sum + = v [I] [len];
Printf ("% lld \ n", sum );
}
Return 0;
}
Description: dizzy. It is always wrong Because gets is used to read the string, but it is correct to read it with scanf. It is speechless. There is a string. The length of the string len represents a matrix of len * len ,? This indicates that a queen can be placed in a row of people in this column. The Queen can only attack one column and target the places around it. numbers and letters are hexadecimal and are represented by n, indicates that there must be a queen in row n of this column. That is to say, this column has been determined to only have this queen.
# Include <cstdio>
# Include <cstring>
# Include <cstdlib>
Long v [20] [20];
Int main ()
{
// Freopen ("a.txt", "r", stdin );
Int len;
Int arr [20];
Char s [50];
Long sum;
While (scanf ("% s", s )! = EOF)
{
Len = strlen (s );
For (int I = 0; I <len; I ++)
If (s [I] = '? ') Arr [I + 1] = 0;
Else if (s [I]> = '1' & s [I] <= '9') arr [I + 1] = s [I]-'0 ';
Else if (s [I]> = 'A' & s [I] <= 'F ') arr [I + 1] = s [I]-'A' + 10;
Memset (v, 0, sizeof (v ));
If (! Arr [1]) for (int I = 1; I <= len; I ++) v [I] [1] = 1;
Else v [arr [1] [1] = 1;
For (int I = 2; I <= len; I ++)
If (! Arr [I])
{
For (int j = 1; j <= len; j ++)
For (int k = 1; k <= len; k ++)
If (abs (k-j)> 1) v [j] [I] + = v [k] [I-1];
}
Else
{
For (int k = 1; k <= len; k ++)
If (abs (k-arr [I])> 1) v [arr [I] [I] + = v [k] [I-1];
}
Sum = 0;
For (int I = 1; I <= len; I ++) sum + = v [I] [len];
Printf ("% lld \ n", sum );
}
Return 0;
}