Deserboy

The Hunting Games

Jun 28th, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.58 KB | None | 0 0
  1. using System;
  2. namespace ConsoleApp47
  3. {
  4.     class Program
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             int days = int.Parse(Console.ReadLine());
  9.             int players = int.Parse(Console.ReadLine());
  10.             double energy = double.Parse(Console.ReadLine());
  11.             double waterPerPerson = double.Parse(Console.ReadLine());
  12.             double foodPerPerson = double.Parse(Console.ReadLine());
  13.             double water = days * waterPerPerson;
  14.             double food = days * foodPerPerson;
  15.             for (int i = 1; i <= days; i++)
  16.             {
  17.                 double energyLoss = double.Parse(Console.ReadLine());
  18.                 energy -= energyLoss;
  19.                 if (energy <= 0)
  20.                 {
  21.                     break;
  22.                 }
  23.                 if (i % 2 == 0)
  24.                 {
  25.                     energy += energy * 0.05;
  26.                     water -= water * 0.3;
  27.                 }
  28.                 if (i % 3 == 0)
  29.                 {
  30.                     food -= food / players;
  31.                     energy += energy * 0.1;
  32.                 }
  33.                 if (energy <= 0)
  34.                 {
  35.                     break;
  36.                 }
  37.             }
  38.             if (energy > 0)
  39.             {
  40.                 Console.WriteLine($"You are ready for the quest. You will be left with - {energy:F2} energy!");
  41.             }
  42.             else
  43.             {
  44.                 Console.WriteLine($"You will run out of energy. You will be left with {food:F2} food and {water:F2} water.");
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment