Loading...

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

VesselinTonchev avatar VesselinTonchev 5 Точки

10. Rage Expenses

Хора, не разбиръм къде бъркам. Задачата се изпълнява коректно, коректно е и форматирането на Output - а. Отгворите са 1:1. Има изискване за време и RAM, което изпълнявам. Защо Judge  ми дава 0/100???

Solution #13898721 by VesselinTonchev for problem 10. Rage Expenses

As a MOBA challenger player, Pesho has the bad habit to trash his PC when he loses a game and rage quits. His gaming setup consists of headset, mouse, keyboard and display. You will receive Pesho`s lost games count. 
Every second lost game, Pesho trashes his headset.
Every third lost game, Pesho trashes his mouse.
When Pesho trashes both his mouse and headset in the same lost game, he also trashes his keyboard.
Every second time, when he trashes his keyboard, he also trashes his display. 
You will receive the price of each item in his gaming setup. Calculate his rage expenses for renewing his gaming equipment. 
Input / Constraints
•	On the first input line - lost games count – integer in the range [0, 1000].
•	On the second line – headset price - floating point number in range [0, 1000]. 
•	On the third line – mouse price - floating point number in range [0, 1000]. 
•	On the fourth line – keyboard price - floating point number in range [0, 1000]. 
•	On the fifth line – display price - floating point number in range [0, 1000]. 
Output
•	As output you must print Pesho`s total expenses: "Rage expenses: {expenses} lv."
•	Allowed working time / memory: 100ms / 16MB.
Examples
Input	Output	Comment
7
2
3
4
5	Rage expenses: 16.00 lv.	Trashed headset -> 3 times
Trashed mouse -> 2 times
Trashed keyboard -> 1 time
Total: 6 + 6 + 4 = 16.00 lv;
23
12.50
21.50
40
200	Rage expenses: 608.00 lv.	

using System;

namespace Rage_Expenses
{
    class Program
    {
        static void Main(string[] args)
        {
            //INPUT
            int lostGames = int.Parse(Console.ReadLine());
            double headsettPrice = double.Parse(Console.ReadLine());
            double mousePrice = double.Parse(Console.ReadLine());
            double keyboardPrice = double.Parse(Console.ReadLine());
            double displayPrice = double.Parse(Console.ReadLine());

            //VARIABLES
            int counter = 0;
            int headsetCount = 0;
            int mouseCount = 0;
            int keyboardCount = 0;
            int displayCount = 0;
            double totalPrice = 0;

            for(int i = 0; i < lostGames; i++)
            {
                if (counter %2 == 0 && counter != 0)
                {
                    headsetCount++;
                    totalPrice += headsettPrice;
                }
                if (counter %3 == 0 && counter != 0)
                {
                    mouseCount++;
                    totalPrice += mousePrice;
                }
                if (counter %6 == 0 && counter != 0)
                {
                    keyboardCount++;
                    totalPrice += keyboardPrice;

                    if (counter %12 == 0)
                    {
                        displayCount++;
                        totalPrice += displayPrice;
                    }
                }
                counter++;
            }
            Console.WriteLine($"Rage expenses: {totalPrice:F2} lv.");
        }
    }
}

 

Тагове:
0
Module: C# Advanced
krum_43 avatar krum_43 750 Точки

Ето ти едно кратко решение и от мен:

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

namespace Rage_expenses
{
    class Program
    {
        static void Main(string[] args)
        {
            int lostgamescount = int.Parse(Console.ReadLine());
            double headsetprice = double.Parse(Console.ReadLine());
            double mouseprice = double.Parse(Console.ReadLine());
            double keybordprice = double.Parse(Console.ReadLine());
            double displayprice = double.Parse(Console.ReadLine());
            double expenses = 0;
            int countoftrechheadsets = lostgamescount / 2;
            int counttrechmouses = lostgamescount / 3;
            int countoftrechkeybords = lostgamescount / 6;
            int countoftrechdisplays = lostgamescount / 12;
            expenses = countoftrechheadsets * headsetprice + counttrechmouses * mouseprice + countoftrechkeybords * keybordprice + countoftrechdisplays * displayprice;
            Console.WriteLine($"Rage expenses: {expenses:f2} lv.");
        }
    }
}

 

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