Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

Ekaterin avatar Ekaterin 133 Точки

Problem 14. * Boat Simulator - ПРОБЛЕМ

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _14.Boat_Simulator
{
    class Program
    {
        static void Main(string[] args)
        {
            char boat1 = char.Parse(Console.ReadLine());
            char boat2 = char.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());
            int upgradeOfFirstBoat = (int)boat1;
            int upgradeOfSecondBoat = (int)boat2;

            int counterofspeedForFirstBoat = 0;
            int counterOfSpeedForSecondBoat = 0;
            for (int i = 1; i <= n; i++)
            {
                string symbols = Console.ReadLine();
                if (i % 2 == 1)
                {
                    counterofspeedForFirstBoat += symbols.Length;
                    if (counterofspeedForFirstBoat >= 50)
                    {
                        Console.WriteLine((char)upgradeOfFirstBoat);
                        break;
                    }
                    if (symbols == "UPGRADE")
                    {
                        upgradeOfFirstBoat += 3;
                        counterofspeedForFirstBoat -= 7;

                    }
                }
                else if (i % 2 == 0)
                {
                    counterOfSpeedForSecondBoat += symbols.Length;
                    if (counterofspeedForFirstBoat >= 50)
                    {
                        Console.WriteLine((char)upgradeOfFirstBoat);
                        break;
                    }
                    if (symbols == "UPGRADE")
                    {
                        upgradeOfSecondBoat += 3;
                        counterOfSpeedForSecondBoat -= 7;
                    }
                }
            }
            if (counterofspeedForFirstBoat < 50 && counterOfSpeedForSecondBoat < 50 && counterofspeedForFirstBoat > counterofspeedForFirstBoat)
            {
                Console.WriteLine((char)upgradeOfFirstBoat);
            }
            else if (counterofspeedForFirstBoat < 50 && counterOfSpeedForSecondBoat < 50 && counterofspeedForFirstBoat < counterOfSpeedForSecondBoat)
            {
                Console.WriteLine((char)upgradeOfSecondBoat);
            }
            
            
        }
    }
}
 

 

 

Тагове:
0
Programming Fundamentals
Ekaterin avatar Ekaterin 133 Точки

Дава ми 57/100 ако някой може да ми каже къде ми е грешката.

Това е условието.

 

Problem 1.* Boat Simulator

You have the task to write a simulator of a boat race. You will receive two characters, which will represent the two boats.

After that you will receive n random strings. Each string on an odd line represents the speed of the first boat and on an even line – the speed of the second boat. The boat moves with the count of the tiles, equal to the length of the given string. The first boat, which reaches 50 tiles is the winner.

Our boats can be upgradable, which means when we receive the string “UPGRADE” we add 3 to the ASCII codes of both of the boats characters and after that, we use those characters to represent the boats. If you receive “UPGRADE”, you should not move the boats.

If one of the boats reaches 50 moves – print the character of the winner and stop taking any input. If neither of the boats reach 50 moves – print the boat, which reached the most moves.

Input

  • On the first line, you will receive the character of the first boat
  • On the second line, you will receive the character of the second boat
  • On the third line, you will receive n – the number of lines, which will follow

Output

Print only the character representation of the winning boat.

Constraints

  • n will be in the interval [1…20]
  • The length of the stings will be between [1…100] characters
  • At the end, the boats will not have equal moves

Examples

Input

Output

Comments

!

(

7

move

need for speed

go

fast and furious

UPGRADE

stopTheBoat

UPGRADE

.

First boat è ‘!’, second boat è ‘(’

move” è 4 letters long è first boat (odd row) moves 4 tiles

need for speed” è 14 letters long è second boat (even row) moves 14 tiles.

go” è 2 letters long è first boat (odd row) moves 2 tiles.

fast and furious” è 16 letters long è second boat moves 16 tiles.

UPGRADE” è add 3 to‘!’ è upgrades to $, add 3 to ( è upgrades to +.

stopTheBoat” è 11 letters long è second boat moves 11 tiles.

UPGRADE”è add 3 to ‘$’ è upgrades to ', add 3 to + è upgrades to ..

Winner – second boat è 41 moves > 6 moves è second boat wins

 

Input

Output

Comments

E

A

10

UPGRADE

start

driveWithTheSpeedOfLight

go

driveWithTheSpeedOfLightOrFaster

Should not be read

a

Should not be read

b

Should not be read

H

We start with an UPGRADE and the first boat is represented by ‘H’ and the second by ‘D

After the 5th line of input the first boat has made 50 moves and you should not take as an input the other lines.

0
pavel1022 avatar pavel1022 0 Точки

Ето ти моя код: https://pastebin.com/Q7uQZC6D

Дано да ти помогне

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.