Codeforces

CF的第一题。不懂题意。所以错了。Q:9  R:5 B:3 N:3 P:1 K:0
A. A and B and Chess
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A and B are preparing themselves for programming contests.

To train their logical thinking and solve problems better, A and B decided to play chess. During the game A wondered whose position is now stronger.

For each chess piece we know its weight:

  • the queen's weight is 9,
  • the rook's weight is 5,
  • the bishop's weight is 3,
  • the knight's weight is 3,
  • the pawn's weight is 1,
  • the king's weight isn't considered in evaluating position.

The player's weight equals to the sum of weights of all his pieces on the board.

As A doesn't like counting, he asked you to help him determine which player has the larger position weight.

Input

The input contains eight lines, eight characters each — the board's description.

The white pieces on the board are marked with uppercase letters, the black pieces are marked with lowercase letters.

The white pieces are denoted as follows: the queen is represented is 'Q', the rook — as 'R', the bishop — as'B', the knight — as 'N', the pawn — as 'P', the king — as 'K'.

The black pieces are denoted as 'q', 'r', 'b', 'n', 'p', 'k', respectively.

An empty square of the board is marked as '.' (a dot).

It is not guaranteed that the given chess position can be achieved in a real game. Specifically, there can be an arbitrary (possibly zero) number pieces of each type, the king may be under attack and so on.

Output

Print "White" (without quotes) if the weight of the position of the white pieces is more than the weight of the position of the black pieces, print "Black" if the weight of the black pieces is more than the weight of the white pieces and print "Draw" if the weights of the white and black pieces are equal.

Sample test(s)
Input
...QK...
........
........
........
........
........
........
...rk...
Output
White
Input
rnbqkbnr
pppppppp
........
........
........
........
PPPPPPPP
RNBQKBNR
Output
Draw
Input
rppppppr
...k....
........
........
........
........
K...Q...
........
Output
Black
Note

In the first test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals 5.

In the second test sample the weights of the positions of the black and the white pieces are equal to 39.

In the third test sample the weight of the position of the white pieces equals to 9, the weight of the position of the black pieces equals to 16.

解答:

#include
#include
int main()
{
    int i,j;
    char a[10][100001];
    int sum=0;
    for(i=0;i<8;i++)
    {
    scanf("%s",a[i]);
    int sd=strlen(a[i]);
        for(j=0;j0)
    printf("White\n");
    else if(sum==0)
    printf("Draw\n");
    else
    printf("Black\n");
    return 0;

}

B题:编译错误,一共四行输入,sort排序不超时

B. A and B and Compilation Errors
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

A and B are preparing themselves for programming contests.

B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.

Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.

However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.

Can you help B find out exactly what two errors he corrected?

Input

The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors.

The second line contains n space-separated integersa1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time.

The third line contains n - 1 space-separated integersb1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.

The fourth line contains n - 2 space-separated integersс1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.

Output

Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.

Sample test(s)
Input
5
1 5 8 123 7
123 7 5 1
5 1 7
Output
8
123
Input
6
1 4 3 3 5 7
3 7 5 4 3
4 3 7 5
Output
1
3
Note

In the first test sample B first corrects the error number 8, then the error number 123.

In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.

解答:
#include
#include
#include
using namespace std;
int b[100100],b1[100010],b2[100010];
int main()
{
    int a,i;
    scanf("%d",&a);
    for(i=0;i
C题:本身没有看,题目不算难,很多方法都能做出来,就是判定的时候少判定了他们是否为零,错了
C. A and B and Team Training
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

A and B are preparing themselves for programming contests.

An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams so that newbies are solving problems together with experienced participants.

A believes that the optimal team of three people should consist of one experienced participant and two newbies. Thus, each experienced participant can share the experience with a large number of people.

However, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.

As a result, A and B have decided that all the teams during the training session should belong to one of the two types described above. Furthermore, they agree that the total number of teams should be as much as possible.

There are n experienced members and m newbies on the training session. Can you calculate what maximum number of teams can be formed?

Input

The first line contains two integers n andm (0 ≤ n, m ≤ 5·105) — the number of experienced participants and newbies that are present at the training session.

Output

Print the maximum number of teams that can be formed.

Sample test(s)
Input
2 6
Output
2
Input
4 5
Output
3
Note

Let's represent the experienced players as XP and newbies as NB.

In the first test the teams look as follows: (XP, NB, NB), (XP, NB, NB).

In the second test sample the teams look as follows: (XP, NB, NB), (XP, NB, NB), (XP, XP, NB).

解答:

#include
int main()
{
    int a,b,sum=0;
    scanf("%d%d",&a,&b);
    while(a>0&&b>0&&a+b>=3)
    {
        if(a>b)
        {
            a=a-2;
            b=b-1;
            sum++;
        }
        else
        {
            a=a-1;
            b=b-2;
            sum++;
        }
    }
    printf("%d\n",sum);
    return 0;
}




你可能感兴趣的:(水题)