ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Linear Data Structures: Arrays > задача:


51091 - Guess the number - 1

Гость
• Вопросы к жюри (1)

Задачи раздела

• 51083 - Grades Histogram
• 51084 - Reflect a matrix
• 51011 - Decoding the Path
• 51088 - Number of letters
• 51172 - The biggest Minute
• 51125 - Filling an Array 3
• 51085 - xyx Divisible by k
• 51087 - Are they the same?
• 51091 - Guess the number - 1
• 51015 - Student Scholarships
• 51008 - Sum of Regional Maxes
• 51020 - Number of nodes removed
• 51141 - Most valuable stock items
• 51014 - Nine Men's Morris game
• 51019 - Finding the hidden message
• 51100 - Minimum time to exit building
• 51089 - Multiply a row and add it to ...

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Ibrahim Mesecan.

Guess the number

There are two kids playing guess the number game. There is a series of random number given (generated by computer). Then, the kids guess a number. The one who guesses closer to the random number wins. The player who has more closer guesses wins the game.

Question: Write a program that is going to read information for n games, and using the functions given the program will decide for the winner. Assume that you are given the following functions and they are working properly (in the library functions.h): #include "utils/functions.h"

  • void getKidNumbers( int &num1, int &num2);
  • int closer( int num1, int num2, int given);
  • void showResult( string s1);
where getKidNumbers gets two numbers into the given parameters; closer function returns 1 if num1 is closer to the given value, returns 2 if num2 is closer to the given value; returns 0 otherwise; showResult function gets 3 possible values: either "The First", or "The Second" or "Draw". Then the function shows the result.

Input specification: You will be first given a number (n). Then the following n lines contain the numbers given. The following n lines contain the guesses by the kids: first number is the guess by the first student where where 0 ≤ n ≤ 25,000

Output specification: If one kid has more wins, (using the function showResult) show "The First" or "The Second". If they have the same number of wins, show the message "Draw".

Sample Input I Sample Input II
5
2
20
18
17
17
16 16
1 12
17 14
20 7
20 12
6
20
9
19
18
19
11
18 1
18 1
12 20
1 3
3 14
3 15
Sample Output I Sample Output II
The First The Second

Explanation: (For sample input 1):

  1. The first number given is 2; both kids guess 16, so it is draw.
  2. The second number given is 20; the first kid guesses 1 and the second kid guesses is 12, so the second kid wins.
  3. The third number given is 18, The first kid is closer (17) and wins.
In total, The first kid wins three times and the second kid wins once. So, the first kid wins.



Для отправки решений необходимо выполнить вход.

www.contester.ru