stefan1919

Student cable

Aug 25th, 2015
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.64 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApplication4
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int counter = 0;
  15.             int cableLength = 0;
  16.             string system = string.Empty;
  17.             int sum = 0;
  18.             int losed = 0;
  19.             while (counter < n)
  20.             {
  21.                 cableLength = int.Parse(Console.ReadLine());
  22.                 system = Console.ReadLine();
  23.                
  24.                
  25.                     if (system == "meters")
  26.                 {
  27.                     sum += (cableLength * 100);
  28.                     losed++;
  29.                 }
  30.                 if (system == "centimeters")
  31.                 {
  32.                     if (cableLength < 20)
  33.                     {
  34.                         sum += 0;  
  35.                     }
  36.                     else
  37.                     {
  38.                         sum += (cableLength);
  39.                         losed++;
  40.                     }
  41.                    
  42.                 }
  43.                
  44.                
  45.                 counter++;
  46.             }
  47.             int cable = (int)(sum - (losed - 1) * 3);
  48.             int output = 0;
  49.             int outputSecond = 0;
  50.             for (int i = 504; i < cable; i+=504)
  51.             {
  52.                 output += 1;
  53.                 outputSecond += 504;
  54.                
  55.             }
  56.            
  57.             Console.WriteLine(output);
  58.             Console.WriteLine(cable - outputSecond);
  59.         }
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment