Deserboy

The Hunting Games

Jun 28th, 2019
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 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 water = double.Parse(Console.ReadLine());
  12.             double food = double.Parse(Console.ReadLine());
  13.             for (int i = 1; i <= days; i++)
  14.             {
  15.                 double energyLoss = double.Parse(Console.ReadLine());
  16.                 energy -= energyLoss;
  17.                 if (energy <= 0)
  18.                 {
  19.                     break;
  20.                 }
  21.                 if (i % 2 == 0)
  22.                 {
  23.                     energy += energy * 0.05;
  24.                     water -= water * 0.3;
  25.                 }
  26.                 else if (i % 3 == 0)
  27.                 {
  28.                     food -= food / players;
  29.                     energy += energy * 0.1;
  30.                 }
  31.                 if (energy <= 0)
  32.                 {
  33.                     break;
  34.                 }
  35.             }
  36.             if (energy > 0)
  37.             {
  38.                 Console.WriteLine($"You are ready for the quest. You will be left with - {energy:F2} energy!");
  39.             }
  40.             else
  41.             {
  42.                 Console.WriteLine($"You will run out of energy. You will be left with {food:F2} food and {water:F2} water.");
  43.             }
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment