Advertisement
wulev

01. Peace Of Cake

Apr 9th, 2014
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.08 KB | None | 0 0
  1. //http://bgcoder.com/Contests/105/Telerik-Academy-Exam-1-5-December-2013-Evening
  2.  
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8.  
  9. namespace _01.PeaceOfCake
  10. {
  11.     class PeaceOfCake
  12.     {
  13.         static void Main(string[] args)
  14.         {
  15.             long a = long.Parse(Console.ReadLine());
  16.             long b = long.Parse(Console.ReadLine());
  17.             long c = long.Parse(Console.ReadLine());
  18.             long d = long.Parse(Console.ReadLine());
  19.  
  20.             decimal nominator = a * d + c * b; //числител
  21.             decimal denominator = b * d; // знаменател
  22.             decimal sum = nominator / denominator;
  23.            
  24.  
  25.             if (sum>=1)
  26.             {
  27.                 Console.WriteLine((long)sum);
  28.                 Console.WriteLine("{0}/{1}",nominator ,denominator);
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine("{0:F22}", (decimal)sum);
  33.                 Console.WriteLine("{0}/{1}", nominator, denominator);
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement