Loading...

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

DragomiraV avatar DragomiraV 0 Точки

09. Padawan Equipment малко помощ

Малко помощ за 09. Padawan Equipment задача, judge ми дава 40 / 100 , а не мога да си открия грешката......

 

  double SumIvancho = double.Parse(Console.ReadLine());
            double studentsCount = int.Parse(Console.ReadLine());
            double sabresPriceOne = double.Parse(Console.ReadLine());
            double robesPriceOne = double.Parse(Console.ReadLine());
            double beltsPriceOne = double.Parse(Console.ReadLine());

            double sabresMore = Math.Ceiling(studentsCount * 10/100);
            double priceSabres = sabresPriceOne * (studentsCount + sabresMore); ///
            double priceBelts = 0;
            double robesPrice = robesPriceOne * studentsCount;

            if (studentsCount >= 6)
            {
                double priceOtstapkaForBelts = Math.Ceiling(studentsCount / 6); //// 
                studentsCount -= priceOtstapkaForBelts;
                priceBelts = beltsPriceOne * studentsCount;
            }
            else
            {
                priceBelts = beltsPriceOne * studentsCount;
            }

            double total = priceSabres + priceBelts + robesPrice;

            double result = Math.Abs(total - SumIvancho);

            if (SumIvancho >= result)
            {
                Console.WriteLine($"The money is enough - it would cost {total:f2}lv.");
            }
            else
            {
                Console.WriteLine($"Ivan Cho will need {result:f2}lv more.");
            }

Тагове:
0
Fundamentals Module
gugibugi avatar gugibugi 12 Точки
Best Answer

using System;

namespace ConsoleApp18
{
    class Program
    {
        static void Main(string[] args)
        {
            double moneyHave = double.Parse(Console.ReadLine());
            double students = double.Parse(Console.ReadLine());
            double saberPrize = double.Parse(Console.ReadLine());
            double robePrize = double.Parse(Console.ReadLine());
            double beltrPrize = double.Parse(Console.ReadLine());
            double costSaber = saberPrize * Math.Ceiling(students * 1.1);
            double costRobe = robePrize * students;
            double costBelts = beltrPrize * (students - Math.Floor(students / 6));
            double sum = costSaber + costRobe + costBelts;
            if (sum <= moneyHave) Console.WriteLine($"The money is enough - it would cost {sum:f2}lv.");
            else Console.WriteLine($"Ivan Cho will need {sum - moneyHave:f2}lv more.");
        }
    }
}

 

0
DragomiraV avatar DragomiraV 0 Точки

Благодаря!!!

0
krum_43 avatar krum_43 750 Точки

Дай линк към условието.

0
DragomiraV avatar DragomiraV 0 Точки

 Eто това е условието:

1.*Padawan Equipment

Yoda is starting his newly created Jedi academy. So, he asked master Ivan Cho to buy the needed equipment. The number of items depends on how many students will sign up. The equipment for the Padawan contains lightsabers, belts and robes.

You will be given the amount of money Ivan Cho has, the number of students and the prices of each item. You have to help Ivan Cho calculate if the money he has is enough to buy all of the equipment, or how much more money he needs.
Because the lightsabres sometimes brakes, Ivan Cho should buy 10% more (taken from the students count), rounded up to the next integer. Also, every sixth belt is free.

Input / Constraints

The input data should be read from the console. It will consist of exactly 5 lines:

  • The amount of money Ivan Cho has – floating-point number in range [0.00…1,000.00]
  • The count of students – integer in range [0…100]
  • The price of lightsabers for a single sabre – floating-point number in range [0.00…100.00]
  • The price of robes for a single robe – floating-point number in range [0.00…100.00]
  • The price of belts for a single belt – floating-point number in range [0.00…100.00]

The input data will always be valid. There is no need to check it explicitly.

Output

The output should be printed on the console.

  • If the calculated price of the equipment is less or equal to the money Ivan Cho has:
    • "The money is enough - it would cost {the cost of the equipment}lv."
  • If the calculated price of the equipment is more than the money Ivan Cho has:
    •  "Ivan Cho will need {neededMoney}lv more."
  • All prices must be rounded to two digits after the decimal point.

Examples

Input

Output

Comments

100

2

1.0

2.0

3.0

The money is enough - it would cost 13.00lv.

Needed equipment for 2 padawans  :

sabresPrice*(studentsCount + 10%) + robesPrice * (studentsCount) + beltsPrice*(studentsCount-freeBelts)

1*(3) + 2*(2) + 3*(2) = 13.00

13.00 <= 100 – the money will be enough.

Input

Output

Comments

100

42

12.0

4.0

3.0

Ivan Cho will need 737.00lv more.

Needed equipment for 42 padawans:

12*47 + 4*42 + 3*35 = 837.00

837 > 100 – need 737.00 lv. more.

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