Home > Back-end >  HF area and the antithesis in 2018
HF area and the antithesis in 2018

Time:10-17

1. Scissors, stone, cloth
(HPS. CPP)
[title description]

You may have heard of "scissors, stone, fabric", many children like to play,
Rules of the game is simple: both count to three, and then a gesture at the same time, on behalf of "scissors", "stone" or "cloth", "stone" wins "scissors" and "scissors" wins "cloth", "cloth" wins "stone", for example, the first children out of the "stone", the second child out of the "cloth", the second child, of course, also can "draw" (if the same two children gesture),
Now give the two children's gesture, please programming to determine the first child is wins the bureau, lost it or flat the innings,

[input format]

One line contains two integers: A and B, respectively, said the two children's gesture, the value of A and B can only be 0,1,2,0 representative on behalf of "scissors", 1 represents "stone", 2 on behalf of the "cloth",

Output format []

A line, contains a character, and character can only for "W", "L", "F", one of the first children if the bureau, output "W"; If the first child lost that game, then output "L"; If the first child for the bureau, the output "F",

[the sample input and output]
Sample input (HPS) in the sample output (HPS) out)
1 2 L

2. The spy
(CPP)
[title description]

Now there are nine scientists are classified together research problems, but according to reliable sources, two of whom are spies, only seven people are the real scientists, cyh classmates want to will the two spy out, of course, these nine people claimed that he was not a spy, fortunately, everyone was wearing a hat, hat there is a positive integer less than 100, according to the latest accurate information, the real seven scientists wearing hat just equal to the sum of the Numbers on the 100, because of cyh students prepare for the final examination, he asked you to write a program to find out the real seven scientists,

[input format]

Input line, a total of 9,
An integer in each row, the first I the integer in the case of a scientist I wear a hat of positive integers,

Output format []

Output line, a total of 7 (because there are only seven scientists),
An integer in each row, the first I the integer in the case of a scientist I wear a hat of positive integers, pay attention to the order of the output is according to remove the order of the two spies,

[1] sample input and output
Sample input (spy) in the sample output (spy. Out)
1
5
6
7
10
12
19
29
33 1
5
6
7
19
29
33


3. The game
(contest. CPP)
[title description]

Yyd is a math enthusiast, he took part in the online math competition, performance was released, he would like to know whether your accomplishments rank, now please help him make up a program, ask for a result, you can know the corresponding rank, note: with the points in the same place, and only once,

[input format]
The first line: an integer n (n 30000) or less
The second line: n positive integers (the number is not greater than 1000),
The third line: an integer, need query score,

Output format []
A total line contains an integer, said query result rankings,

[the sample input and output]
Sample input (contest) in the sample output (contest) out)
7
30 to 50 80 60 20 50 to 60
50 4

The number of 4.0
(num. CPP)
[problem description]
Enter a positive integer N (N 1000000000) or less, output N! The Numbers of 0, at the end of the (N!=1 x 2 x 3 x... X N),

[enter]
Input file contains a positive integer n, no more than 1000000000
[output]
Output file just output an integer, said N! The Numbers of 0, at the end of the

[example]
The sample input (num.) in the sample output (num. Out)
5 1

T1:
The first question,
Nothing to speak of,
If the else is ok,
Write a win and a draw conditions respectively,
Specific conditions here:
Win (W) :
A=1, b=0
A=2, b=1
A=3, b=2
Lose (L) :
A=0, b=1
A=1, b=2
A=2, b=3
Flat (F) :
A=b
So,
The main function of the code is as follows:
(don't copy, because is wrong!
 
Freopen (HPS) "in", "r", stdin);
Freopen (HPS) "out", "w", stdout);//file operations don't forget to write!
Cin> a> b;//read in a and b
If (a==b)
{
Cout<& lt;" F ";//if a and b are equal, then draw the output F,
}
Else if (a==0 & amp; & B==1) | | (a==1 & amp; & B==2) | | (a==2 & amp; & B==0))
{
Cout<& lt;" L ";//if the above value, then lose, output L,
}
The else cout<& lt;" W ";//if the previous neither, then win, output W,

The complete code is as follows:
 
#include
using namespace std;
int a,b;
Int main ()
{
Freopen (HPS) "in", "r", stdin);
Freopen (HPS) "out", "w", stdout);
Cin> a> b;
If (a==b)
{
Cout<& lt;" F ";
}
Else if (a==0 & amp; & B==1) | | (a==1 & amp; & B==2) | | (a==2 & amp; & B==0))
{
Cout<& lt;" L ";
}
The else cout<& lt;" W ";
return 0;
}

T2:
This problem if using ordinary "nine heavy cycle" to do,
Should be,
Because of a 9 of 9 square early timeout
So I need a better way,
Someone said,
Can use the "seventh circle"!
Small make up with a calculator to calculate again,
Indeed there is no timeout,
Small make up recommend, however,
Can use a more easy way!

In fact, you want to,
To find out what scientists,
Need to find out what are spies,
Scientists and seven hats on the sum of 100,
Then the sum of two spy hat number,
Hat is all the sum - 100,
In this way,
As long as find
Which two hats on the sum,
Equal to the number all hat - 100, the sum of
So,
The two men is a spy!
Program implementation is as follows:
 
for(i=1; i<=9; I++) {
Cin> A, [I].
S +=a, [I].
}

First of all,
With the Numbers on the loop will each hat,
And its accumulative
 
S -=100;

The total value minus 100, the
Is the sum of two spy hat number
 
for(i=1; i<=9; I++) {
For (j=I + 1; J<=9; J++) {
If (a + [I] a [j]==s) {
A [I]=0;
A [j]=0;
break;
}
}
}

Use a double loop one by one, the enumeration,
If the additive is equal to s,
Two men as spies,
And put two values to 0
 
for(i=1; i<=9; I++) {
If (a [I]!=0) cout}

The final output part,
If not 0,
That is the real scientists,
The complete code is as follows:
 
#include
using namespace std;
Long long a [8], p, q, I, s, j.
Int main ()
{
Freopen (" spy. In ", "r", stdin);
Freopen (" spy out ", "w", stdout);
for(i=1; i<=9; I++) {
Cin> A, [I].
S +=a, [I].
}
S -=100;
for(i=1; i<=9; I++) {
For (j=I + 1; J<=9; J++) {
If (a + [I] a [j]==s) {
A [I]=0;
A [j]=0;
break;
}
}
}
for(i=1; i<=9; I++) {
If (a [I]!=0) cout
}
return 0;
}

T3:
The third question,
Needless to say,
So the typical subject,
If you don't do,
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related