PShterev 0 Точки

## Здравейте,

може ли някой да ми помогне с решението на тази задача? В Judge, следният код ми дава 60/100:

using System;

namespace PokeMon
{
class Program
{
static void Main(string[] args)
{
int pokePowerCurrent = pokePower;
int hitTargets = 0;

do
{
pokePowerCurrent -= distanceBetwTargets;
hitTargets++;

if (pokePowerCurrent == pokePower / 2.0 && exhaustionFactor != 0)
{
pokePowerCurrent = pokePowerCurrent / exhaustionFactor;
}

} while (pokePowerCurrent > distanceBetwTargets);

Console.WriteLine(pokePowerCurrent);
Console.WriteLine(hitTargets);
}
}
}

Благодаря предварително.

Тагове:
0
Axiomatik 791 Точки

Best,

using System;

namespace PokeMon
{
class Program
{
static void Main(string[] args)
{
double pokePowerCurrent = pokePower * 0.5;
int hitTargets = 0;

//do
//{
//    pokePowerCurrent -= distanceBetwTargets;
//    hitTargets++;

//    if (pokePowerCurrent == pokePower / 2.0 && exhaustionFactor != 0)
//    {
//        pokePowerCurrent = pokePowerCurrent / exhaustionFactor;
//    }

//} while (pokePowerCurrent > distanceBetwTargets);

while (pokePowerCurrent >= distanceBetwTargets)
{
hitTargets++;
pokePowerCurrent -= distanceBetwTargets;

if (pokePower == pokePowerCurrent)
{
pokePower /= exhaustionFactor;
}
}

Console.WriteLine(pokePowerCurrent);
Console.WriteLine(hitTargets);
}
}
}

0