Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.59 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. class Program
  6. {
  7.     static void Main()
  8.     {
  9.         long input = long.Parse(Console.ReadLine());
  10.         long inputDouble = 0;
  11.         inputDouble = input;
  12.         long immuneSystemHealth = 0;
  13.         immuneSystemHealth = inputDouble;
  14.         var virus = Console.ReadLine().ToList();;
  15.         var foughtVirusesList = new List<long>();
  16.         while (string.Join("", virus) != "end")
  17.         {
  18.             long virusStrenghtCalculated = 0;
  19.             long virusTimeToDefeatSeconds = 0;
  20.             string virusTimeToDeafeatMinutesFormatted = string.Empty;
  21.  
  22.             for (int i = 0; i < virus.Count; i++)
  23.             {
  24.                 virusStrenghtCalculated += virus[i];                                  
  25.             }
  26.             virusStrenghtCalculated /= 3;
  27.            
  28.             virusTimeToDefeatSeconds = virusStrenghtCalculated * virus.Count();
  29.             for (int i = 0; i < foughtVirusesList.Count; i++)
  30.             {
  31.                 if (virusStrenghtCalculated == foughtVirusesList[i])
  32.                 {
  33.                     virusTimeToDefeatSeconds = (virusStrenghtCalculated * virus.Count()) / 3;
  34.                 }                                              
  35.             }
  36.             foughtVirusesList.Add(virusStrenghtCalculated);
  37.             double seconds = virusTimeToDefeatSeconds % 60;
  38.             double minutes = virusTimeToDefeatSeconds / 60;
  39.             Convert.ToInt32(immuneSystemHealth);
  40.             immuneSystemHealth -= virusTimeToDefeatSeconds;
  41.            
  42.            
  43.             if (immuneSystemHealth > 0)
  44.             {
  45.                 Console.WriteLine($"Virus {string.Join("", virus)}: {virusStrenghtCalculated} => {virusTimeToDefeatSeconds} seconds" +
  46.                     $"\n{string.Join("", virus)} defeated in {minutes}m {seconds}s.\nRemaining health: {immuneSystemHealth}");
  47.                 var percentCalculation =+ immuneSystemHealth * 0.20;
  48.                 immuneSystemHealth += (long)percentCalculation;
  49.                 if (immuneSystemHealth > inputDouble)
  50.                 {
  51.                     immuneSystemHealth = inputDouble;
  52.                 }
  53.             }
  54.             else
  55.             {
  56.                 Console.WriteLine($"Virus {string.Join("", virus)}: {virusStrenghtCalculated} => {virusTimeToDefeatSeconds} seconds");
  57.                 Console.WriteLine("Immune System Defeated.");
  58.                 return;
  59.             }
  60.  
  61.             virus = Console.ReadLine().ToList();
  62.         }
  63.         Console.WriteLine($"Final Health: {immuneSystemHealth}");
  64.  
  65.  
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement