Advertisement
EmoRz

Raindear_Forecast_Agency

May 3rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace p01
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             //Raindrops
  12.             var regions = byte.Parse(Console.ReadLine());
  13.             var denisity = float.Parse(Console.ReadLine());
  14.             var sum = 0.0;
  15.  
  16.             for (int i = 0; i < regions; i++)
  17.             {
  18.                 string[] info = Console.ReadLine().Split(' ').ToArray();
  19.                 long raindropsCount = long.Parse(info[0]);
  20.                 int squareMeters = int.Parse(info[1]);
  21.                 double calc = raindropsCount*1.0 / squareMeters;
  22.                 sum += calc;
  23.             }
  24.             var first = sum / denisity;
  25.             if (denisity != 0)
  26.             {
  27.                 Console.WriteLine($"{first:f3}");
  28.             }
  29.             else
  30.             {
  31.                 Console.WriteLine($"{sum:f3}");
  32.             }
  33.  
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement