kvadrat4o

Immune System

Jun 16th, 2017
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. /*
  2.  * Created by SharpDevelop.
  3.  * User: DVasilev
  4.  * Date: 2017/06/16
  5.  * Time: 10:41 AM
  6.  *
  7.  * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8.  */
  9. using System;
  10. using System.Linq;
  11. using System.Collections.Generic;
  12.  
  13.  
  14. namespace ImmuneSystem
  15. {
  16.     class Program
  17.     {
  18.         public static void Main(string[] args)
  19.         {
  20.             //Console.WriteLine("Hello World!");
  21.             int organismHealth = int.Parse(Console.ReadLine());
  22.             var virusDataBase = new Dictionary<string, Dictionary<int,int>>();
  23.             var line = Console.ReadLine();
  24.             if (line != "end")
  25.             {
  26.                 while (line != "end")
  27.                 {
  28.                     var virusName = line;
  29.                     var virusStrength = virusName.ToList().Select(x => (int)x).Sum() / 3;
  30.                     var timeToDefeat = virusStrength * virusName.Length;
  31.                     if (virusDataBase.ContainsKey(virusName))
  32.                     {
  33.                         timeToDefeat =  (virusStrength * virusName.Length) / 3;
  34.                     }
  35.                     var timeMin = timeToDefeat / 60;
  36.                     var timeSec = timeToDefeat % 60;
  37.                     var diff = organismHealth - timeToDefeat;
  38.                     Console.WriteLine("Virus {0}: {1} => {2} seconds",virusName,virusStrength,timeToDefeat);
  39.                     var renewed = 0;
  40.                     if (organismHealth > timeToDefeat)
  41.                     {
  42.                         Console.WriteLine("{0} defeated in {1}m {2}s.",virusName,timeMin,timeSec);
  43.                         renewed = organismHealth + (organismHealth*20) / 100;
  44.                         if (renewed > organismHealth)
  45.                         {
  46.                             renewed = organismHealth;
  47.                         }
  48.                     }
  49.                     else
  50.                     {
  51.                         Console.WriteLine("Immune System Defeated.");
  52.                         break;
  53.                     }
  54.                     Console.WriteLine("Remaining health: {0}",diff);
  55.                     line = Console.ReadLine();
  56.                 }
  57.             }
  58.             else
  59.             {
  60.                 Console.WriteLine("Final health: {0}",organismHealth);
  61.             }
  62.             Console.Write("Press any key to continue . . . ");
  63.             Console.ReadKey(true);
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment