Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Created by SharpDevelop.
- * User: DVasilev
- * Date: 2017/06/16
- * Time: 10:41 AM
- *
- * To change this template use Tools | Options | Coding | Edit Standard Headers.
- */
- using System;
- using System.Linq;
- using System.Collections.Generic;
- namespace ImmuneSystem
- {
- class Program
- {
- public static void Main(string[] args)
- {
- //Console.WriteLine("Hello World!");
- int organismHealth = int.Parse(Console.ReadLine());
- var virusDataBase = new Dictionary<string, Dictionary<int,int>>();
- var line = Console.ReadLine();
- if (line != "end")
- {
- while (line != "end")
- {
- var virusName = line;
- var virusStrength = virusName.ToList().Select(x => (int)x).Sum() / 3;
- var timeToDefeat = virusStrength * virusName.Length;
- if (virusDataBase.ContainsKey(virusName))
- {
- timeToDefeat = (virusStrength * virusName.Length) / 3;
- }
- var timeMin = timeToDefeat / 60;
- var timeSec = timeToDefeat % 60;
- var diff = organismHealth - timeToDefeat;
- Console.WriteLine("Virus {0}: {1} => {2} seconds",virusName,virusStrength,timeToDefeat);
- var renewed = 0;
- if (organismHealth > timeToDefeat)
- {
- Console.WriteLine("{0} defeated in {1}m {2}s.",virusName,timeMin,timeSec);
- renewed = organismHealth + (organismHealth*20) / 100;
- if (renewed > organismHealth)
- {
- renewed = organismHealth;
- }
- }
- else
- {
- Console.WriteLine("Immune System Defeated.");
- break;
- }
- Console.WriteLine("Remaining health: {0}",diff);
- line = Console.ReadLine();
- }
- }
- else
- {
- Console.WriteLine("Final health: {0}",organismHealth);
- }
- Console.Write("Press any key to continue . . . ");
- Console.ReadKey(true);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment