Advertisement
Guest User

Untitled

a guest
Dec 6th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 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. using System.Numerics;
  7.  
  8. namespace _01_AMericanPie
  9. {
  10.     class Program
  11.     {
  12.         static void Main(string[] args)
  13.         {
  14.             BigInteger A = BigInteger.Parse(Console.ReadLine());
  15.             //int A = 2;   BigInteger
  16.             BigInteger B = BigInteger.Parse(Console.ReadLine());
  17.             //int B = 4;   BigInteger
  18.             BigInteger C = BigInteger.Parse(Console.ReadLine());
  19.             //int C = 2;   BigInteger
  20.             BigInteger D = BigInteger.Parse(Console.ReadLine());
  21.             //int D = 3;
  22.  
  23.             BigInteger G = B * D;
  24.             BigInteger nominatorAAdd = G / B;
  25.             A = A * nominatorAAdd;
  26.  
  27.             BigInteger nominatorCAdd = G / D;
  28.             C = C * nominatorCAdd;
  29.  
  30.             BigInteger F = A + C;
  31.  
  32.             BigInteger numberOfFullPies = F / G;
  33.  
  34.             if (numberOfFullPies > 0)
  35.             {
  36.                 Console.WriteLine(numberOfFullPies);
  37.                 Console.WriteLine("{0}/{1}", F, G);
  38.             }
  39.  
  40.             else if (numberOfFullPies == 0)
  41.             {
  42.                 decimal halfPie = (decimal)F / (decimal)G;
  43.                 Console.WriteLine("{0:F20}", halfPie);
  44.                 Console.WriteLine("{0}/{1}", F, G);
  45.                
  46.             }
  47.  
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement