Advertisement
n4wn4w

2zadacha8variant

Mar 18th, 2015
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. 8////////////////////////////////////////////////////////////////////////////////////////
  2.  int n = int.Parse(Console.ReadLine());
  3.         int totalLength = 0;
  4.        
  5.         for (int i = 0; i < n; i++)
  6.         {
  7.             int length = int.Parse(Console.ReadLine());
  8.             string measure = Console.ReadLine();
  9.             if (measure == "meters")
  10.             {
  11.                 // Convert meters to centimeters
  12.                 length = length * 100;
  13.             }
  14.             if (length >= 20)
  15.             {
  16.                 totalLength = totalLength + (length - 3);  
  17.             }
  18.         }
  19.  
  20.         // Substract the lost length for joining the cables
  21.         totalLength += 3;
  22.  
  23.         int cablesCount = totalLength / 504;
  24.         int remainder = totalLength % 504;
  25.  
  26.         Console.WriteLine(cablesCount);
  27.         Console.WriteLine(remainder);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement