Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //http://bgcoder.com/Contests/105/Telerik-Academy-Exam-1-5-December-2013-Evening
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _01.PeaceOfCake
- {
- class PeaceOfCake
- {
- static void Main(string[] args)
- {
- long a = long.Parse(Console.ReadLine());
- long b = long.Parse(Console.ReadLine());
- long c = long.Parse(Console.ReadLine());
- long d = long.Parse(Console.ReadLine());
- decimal nominator = a * d + c * b; //числител
- decimal denominator = b * d; // знаменател
- decimal sum = nominator / denominator;
- if (sum>=1)
- {
- Console.WriteLine((long)sum);
- Console.WriteLine("{0}/{1}",nominator ,denominator);
- }
- else
- {
- Console.WriteLine("{0:F22}", (decimal)sum);
- Console.WriteLine("{0}/{1}", nominator, denominator);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement