Loading...

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

danail2003 avatar danail2003 27 Точки

11. *Snowballs

Здравейте, дава ми 90/100. Благодаря предварително!

 

using System;

namespace Snowballs
{
    class Program
    {
        static void Main(string[] args)
        {
            int number = int.Parse(Console.ReadLine());
            int counter = 0;
            double maxValue = double.MinValue;
            int endSnowball = 0;
            int endSnowballTime = 0;
            int endSnowballQuality = 0;

            while (counter < number)
            {
                int snowball = int.Parse(Console.ReadLine());
                int snowballTime = int.Parse(Console.ReadLine());
                int snowballQuality = int.Parse(Console.ReadLine());
                double formula = Math.Pow(snowball / snowballTime, snowballQuality);               

                if (formula > maxValue)
                {
                    maxValue = formula;
                    endSnowball = snowball;
                    endSnowballTime = snowballTime;
                    endSnowballQuality = snowballQuality;
                }

                counter++;
            }
            Console.WriteLine($"{endSnowball} : {endSnowballTime} = {maxValue} ({endSnowballQuality})");
        }
    }
}
 

*Snowballs

Tony and Andi love playing in the snow and having snowball fights, but they always argue which makes the best snowballs. They have decided to involve you in their fray, by making you write a program, which calculates snowball data, and outputs the best snowball value.

You will receive N – an integer, the number of snowballs being made by Tony and Andi.
For each snowball you will receive 3 input lines:

  • On the first line you will get the snowballSnow – an integer.
  • On the second line you will get the snowballTime – an integer.
  • On the third line you will get the snowballQuality – an integer.

For each snowball you must calculate its snowballValue by the following formula:

(snowballSnow / snowballTime) ^ snowballQuality

At the end you must print the highest calculated snowballValue.

Input

  • On the first input line you will receive N – the number of snowballs.
  • On the next N * 3 input lines you will be receiving data about snowballs.

Output

  • As output you must print the highest calculated snowballValue, by the formula, specified above.
  • The output format is:
    {snowballSnow} : {snowballTime} = {snowballValue} ({snowballQuality})

Constraints

  • The number of snowballs (N) will be an integer in range [0, 100].
  • The snowballSnow is an integer in range [0, 1000].
  • The snowballTime is an integer in range [1, 500].
  • The snowballQuality is an integer in range [0, 100].
Тагове:
0
Fundamentals Module
svetoslav_0 avatar svetoslav_0 1009 Точки

Здравей! 

Решавал съм тази задача преди доста време, но мисля, че се сещам къде е проблемът тук. Math.Pow връща double, а резултатът на последния тест е много по-голяма стойност от тази, която би могла да побере double. Решението е просто: напиши си един метод (например pow), които да връща много по-големи стойности, например long. 

Успех!

1
24/07/2019 21:34:02
danail2003 avatar danail2003 27 Точки

Благодаря!

1
silly19 avatar silly19 1 Точки

Nice blog, the article you have shared is good.This article is very useful. My friend suggest me to use this blog. top school in greater noida

-1
Elena123456 avatar Elena123456 235 Точки

Здравейте, ще съм благодарна за малко помощ за тази задача.

Judge също ми дава 90/100, при положение, че направих след Math.Pow метода да връща long и да ми записва числото, като long. Също така опитах и всичко да запиша в long, но отново 90/100. Вероятно проблема е и някъде другъде.

 


using System;

namespace DataExercise
{
    class MainClass
    {

        public static void Main()
        {
            int numOfSnowballs = int.Parse(Console.ReadLine());
            long maxSnowballValue = 0;
            int maxSnowballSnow = 0;
            int maxSnowballTime = 0;
            int maxSnowballQuality = 0;


            for (int i = 0; i < numOfSnowballs; i++)
            {
                int snowballSnow = int.Parse(Console.ReadLine());
                int snowballTime = int.Parse(Console.ReadLine());
                int snowballQuality = int.Parse(Console.ReadLine());

                long snowballValue  = (long)Math.Pow(snowballSnow / snowballTime, snowballQuality);

                if (snowballValue > maxSnowballValue)
                {
                    maxSnowballValue = snowballValue;
                    maxSnowballSnow = snowballSnow;
                    maxSnowballTime = snowballTime;
                    maxSnowballQuality = snowballQuality;
                }

            }


            Console.WriteLine($"{maxSnowballSnow} : {maxSnowballTime} = {maxSnowballValue} ({maxSnowballQuality})");

 


        }

    }
}

 

 

0
chrisi2712 avatar chrisi2712 272 Точки

Здравей, смени long с BigInteger и ще стане

 

using System;
using System.Numerics;

namespace DataExercise
{
    class MainClass
    {

        public static void Main()
        {
            int numOfSnowballs = int.Parse(Console.ReadLine());
            BigInteger maxSnowballValue = 0;
            int maxSnowballSnow = 0;
            int maxSnowballTime = 0;
            int maxSnowballQuality = 0;


            for (int i = 0; i < numOfSnowballs; i++)
            {
                int snowballSnow = int.Parse(Console.ReadLine());
                int snowballTime = int.Parse(Console.ReadLine());
                int snowballQuality = int.Parse(Console.ReadLine());

                 BigInteger snowballValue  = BigInteger.Pow(snowballSnow / snowballTime, snowballQuality);

                if (snowballValue > maxSnowballValue)
                {
                    maxSnowballValue = snowballValue;
                    maxSnowballSnow = snowballSnow;
                    maxSnowballTime = snowballTime;
                    maxSnowballQuality = snowballQuality;
                }

            }


            Console.WriteLine($"{maxSnowballSnow} : {maxSnowballTime} = {maxSnowballValue} ({maxSnowballQuality})");

 


        }

    }
}

2
12/06/2020 23:16:15
Elena123456 avatar Elena123456 235 Точки

Много благодаря! :) 

Поздрави!

 

0
coolastro avatar coolastro 5 Точки

656 angel number Thank you for sharing this information with us in a simple language I'm also a blogger and write meaningful content. I got this inspiration of writing through blogs posts like this website.

-1
bekean avatar bekean -2 Точки

In this code, we first read the integer n from the wordle input, which represents the number of snowballs. We then initialize a variable max_value to 0, which will keep track of the maximum snowballValue seen so far.

-1
jordanmaddox avatar jordanmaddox 3 Точки

За да получите пълния брой точки, най-вероятно трябва само да добавите принтиране на съобщението "Incorrect password. Try again." след всяка грешна парола dino game, преди да прочетете отново паролата.

0
Zephyr avatar Zephyr 2 Точки

I would like to present to you a geometry dash meltdown game that is entertaining as well as useful. Always complete important and beneficial jobs
 

0
edenwheeler avatar edenwheeler 3 Точки

Hello,

The provided C# program calculates the highest snowball value among a given number of snowballs based on input parameters (snowballSnow, snowballTime, snowballQuality). The program utilizes a for loop to iterate through the snowballs, calculates each snowball's value using a specified formula, gcp online training and tracks the maximum value along with its corresponding parameters. The final output displays the snowball with the highest calculated value, formatted as "snowballSnow : snowballTime = snowballValue (snowballQuality)." The revised code includes improvements for clarity, readability, and precision in variable names and calculations.

I hope this will help you.

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