deleriumbg

Blockchain Dev Course

May 30th, 2018
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.56 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Dragons_Hatching
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int teams = int.Parse(Console.ReadLine());
  10.             double dragonsHatchingValue = double.Parse(Console.ReadLine());
  11.             double sum = 0;
  12.  
  13.             for (int i = 0; i < teams; i++)
  14.             {
  15.                 string[] input = Console.ReadLine().Split(' ');
  16.                 long dragonsHatched = long.Parse(input[0]);
  17.                 long teamMembersCount = long.Parse(input[1]);
  18.                 double teamPoints = (double)dragonsHatched / teamMembersCount;
  19.                 sum += teamPoints;
  20.             }
  21.             if (dragonsHatchingValue != 0)
  22.             {
  23.                 double result = sum / dragonsHatchingValue;
  24.                 Console.WriteLine($"{result:f3}");
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine($"{sum:f3}");
  29.             }
  30.            
  31.            
  32.         }
  33.     }
  34. }
  35.  
  36.  
  37. using System;
  38.  
  39. namespace Survival_Message
  40. {
  41.     class Program
  42.     {
  43.         static void Main(string[] args)
  44.         {
  45.             int firstNum = int.Parse(Console.ReadLine());
  46.             char firstUpper = char.Parse(Console.ReadLine().ToUpper());
  47.             char lowerLetter = char.Parse(Console.ReadLine().ToLower());
  48.             char secondUpper = char.Parse(Console.ReadLine().ToUpper());
  49.             int fifthNum = int.Parse(Console.ReadLine());
  50.             int count = int.Parse(Console.ReadLine());
  51.             int counter = 0;
  52.  
  53.             for (int i = firstNum; i <= 99; i++)
  54.             {
  55.                 for (char j = firstUpper; j <= 'Z'; j++)
  56.                 {
  57.                     for (char k = lowerLetter; k <= 'z'; k++)
  58.                     {
  59.                         for (char m = secondUpper; m <= 'Z'; m++)
  60.                         {
  61.                             for (int n = fifthNum; n >= 10; n--)
  62.                             {
  63.                                 if (i % 10 == 2 && n % 10 == 5)
  64.                                 {
  65.                                     counter++;
  66.                                     if (counter == count)
  67.                                     {
  68.                                         Console.WriteLine($"{i}{j}{k}{m}{n}");
  69.                                         Environment.Exit(0);
  70.                                     }
  71.                                 }
  72.                             }
  73.                         }
  74.                     }
  75.                 }
  76.             }
  77.         }
  78.     }
  79. }
  80.  
  81.  
  82. using System;
  83. using System.Collections.Generic;
  84. using System.Linq;
  85.  
  86. namespace The_Great_Samurai_Battle
  87. {
  88.     class Program
  89.     {
  90.         static void Main(string[] args)
  91.         {
  92.             List<int> samuraiMasters = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
  93.  
  94.             bool[] deadIndexes = new bool[samuraiMasters.Count];
  95.             for (int i = 0; i < samuraiMasters.Count; i++)
  96.             {
  97.                 deadIndexes[i] = true;
  98.             }
  99.             int trueCount = deadIndexes.Count(x => x);
  100.             int sequenceLength = samuraiMasters.Count;
  101.  
  102.             while (trueCount != 1)
  103.             {
  104.                 for (int attackerIndex = 0; attackerIndex < sequenceLength; attackerIndex++)
  105.                 {
  106.  
  107.                     if (deadIndexes.Count(x => x)==1)
  108.                     {
  109.                         return;
  110.                     }
  111.                     if (deadIndexes[attackerIndex] == false)
  112.                     {
  113.                         continue;
  114.                     }
  115.                     int targetIndex = samuraiMasters[attackerIndex] % trueCount;
  116.                     int difference = Math.Abs(attackerIndex - targetIndex);
  117.                     if (difference == 0)
  118.                     {
  119.                         deadIndexes[attackerIndex] = false; ;
  120.                         Console.WriteLine($"{attackerIndex} performed harakiri");
  121.                     }
  122.                     else if (difference % 2 != 0)
  123.                     {
  124.                         deadIndexes[attackerIndex] = false; ;
  125.                         Console.WriteLine($"{attackerIndex} x {targetIndex} -> {targetIndex} wins");
  126.                     }
  127.                     else if (difference % 2 == 0)
  128.                     {
  129.                         deadIndexes[targetIndex] = false;
  130.                         Console.WriteLine($"{attackerIndex} x {targetIndex} -> {attackerIndex} wins");
  131.                     }
  132.                  
  133.                 }
  134.                 trueCount = deadIndexes.Count(x => x);
  135.             }
  136.         }
  137.     }
  138. }
Advertisement
Add Comment
Please, Sign In to add comment