Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ImmuneSystem
- {
- class Program
- {
- static void Main(string[] args)
- {
- var line = Console.ReadLine();
- var immuneSystem = new List<string>();
- double startHealth = double.Parse(line);
- double health = double.Parse(line);
- while (true)
- {
- int virusStrength = 0;
- int virStr = 0;
- int timeToDefeatInSec = 0;
- line = Console.ReadLine();
- if (line == "end")
- {
- health = health * 0.20 + health;
- Console.WriteLine($"Final Health: {Math.Abs(health):f0}");
- break;
- }
- if (!immuneSystem.Contains(line))
- {
- immuneSystem.Add(line);
- foreach (var letter in line)
- {
- var virus = letter;
- virusStrength += virus;
- virStr = virusStrength / 3;
- timeToDefeatInSec = virStr * line.Length;
- }
- health = health * 0.20 + health;
- if (health > 0)
- {
- if (health > startHealth)
- {
- health = startHealth;
- }
- health = health - timeToDefeatInSec;
- Console.WriteLine($"Virus {line}: {virStr:f0} => {timeToDefeatInSec:f0} seconds");
- Console.WriteLine($"{line} defeated in {timeToDefeatInSec / 60:f0}m {timeToDefeatInSec % 60:f0}s.");
- Console.WriteLine($"Remaining health: {Math.Abs(health):f0}");
- }
- }
- else if (immuneSystem.Contains(line))
- {
- foreach (var letter in line)
- {
- var virus = letter;
- virusStrength += virus;
- virStr = virusStrength / 3;
- timeToDefeatInSec = (virStr * line.Length) /3;
- }
- health = health * 0.20 + health;
- if (health > 0)
- {
- if (health > startHealth)
- {
- health = startHealth;
- }
- health = health - timeToDefeatInSec;
- Console.WriteLine($"Virus {line}: {virStr:f0} => {timeToDefeatInSec:f0} seconds");
- Console.WriteLine($"{line} defeated in {timeToDefeatInSec / 60:f0}m {timeToDefeatInSec % 60:f0}s.");
- Console.WriteLine($"Remaining health: {Math.Abs(health):f0}");
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement