  danail2003 30 Точки

## 11. *Snowballs

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

using System;

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

while (counter < number)
{
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 Elena123456 166 Точки

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

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

using System;

namespace DataExercise
{
class MainClass
{

public static void Main()
{
long maxSnowballValue = 0;
int maxSnowballSnow = 0;
int maxSnowballTime = 0;
int maxSnowballQuality = 0;

for (int i = 0; i < numOfSnowballs; i++)
{

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 271 Точки

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

using System;
using System.Numerics;

namespace DataExercise
{
class MainClass
{

public static void Main()
{
BigInteger maxSnowballValue = 0;
int maxSnowballSnow = 0;
int maxSnowballTime = 0;
int maxSnowballQuality = 0;

for (int i = 0; i < numOfSnowballs; i++)
{

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 166 Точки

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

Поздрави!

0