Advertisement
Pietras286

Predkość średnia

Dec 13th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 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 Probelm29
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int t = int.Parse(Console.ReadLine());
  14.             for (int i = 0; i < t; i++)
  15.             {
  16.                 string[] tab = Console.ReadLine().Split(' ');
  17.                 int a = int.Parse(tab[0]);
  18.                 int b = int.Parse(tab[1]);
  19.                 if(a < b)
  20.                 {
  21.                     int tmp = a;
  22.                     a = b;
  23.                     b = tmp;
  24.                 }
  25.                 int s = 2 * a;
  26.                 float T = 1 + (float)a / (float)b;
  27.                 Console.WriteLine(Math.Round(s/T));
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement