Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 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 foughtVirusesDict = new Dictionary<string, 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.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38. if (!foughtVirusesDict.ContainsKey(string.Join("", virus)))
  39. {
  40. foughtVirusesDict[string.Join("", virus)] = virusTimeToDefeatSeconds;
  41. }
  42. else
  43. {
  44. virusTimeToDefeatSeconds = foughtVirusesDict[string.Join("", virus)] / 3;
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. double seconds = virusTimeToDefeatSeconds % 60;
  53. double minutes = virusTimeToDefeatSeconds / 60;
  54. Convert.ToInt32(immuneSystemHealth);
  55. immuneSystemHealth -= virusTimeToDefeatSeconds;
  56.  
  57.  
  58. if (immuneSystemHealth > 0)
  59. {
  60. Console.WriteLine($"Virus {string.Join("", virus)}: {virusStrenghtCalculated} => {virusTimeToDefeatSeconds} seconds" +
  61. $"\n{string.Join("", virus)} defeated in {minutes}m {seconds}s.\nRemaining health: {immuneSystemHealth}");
  62. var percentCalculation = +immuneSystemHealth * 0.20;
  63. immuneSystemHealth += (long)percentCalculation;
  64. if (immuneSystemHealth > inputDouble)
  65. {
  66. immuneSystemHealth = inputDouble;
  67. }
  68. }
  69. else
  70. {
  71. Console.WriteLine($"Virus {string.Join("", virus)}: {virusStrenghtCalculated} => {virusTimeToDefeatSeconds} seconds");
  72. Console.WriteLine("Immune System Defeated.");
  73. return;
  74. }
  75.  
  76. virus = Console.ReadLine().ToList();
  77. }
  78. Console.WriteLine($"Final Health: {immuneSystemHealth}");
  79.  
  80.  
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement