Advertisement
Guest User

Untitled

a guest
Aug 31st, 2017
479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 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 Exam101
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int m = int.Parse(Console.ReadLine());
  15.             int y = int.Parse(Console.ReadLine());
  16.  
  17.             double nDividedByTwo = n / 2.0;
  18.  
  19.             int cnt = 0;
  20.             while (n >= m)
  21.             {
  22.                 if (n == nDividedByTwo)
  23.                 {
  24.                     if(y != 0)
  25.                     {
  26.                         n = n / y;
  27.                     }
  28.                     if (n >= m)
  29.                     {
  30.                         n = n - m;
  31.                         cnt++;
  32.                     }
  33.                 }
  34.                 else
  35.                 {
  36.                     n = n - m;
  37.                     cnt++;
  38.                 }
  39.                
  40.             }
  41.             Console.WriteLine(n);
  42.             Console.WriteLine(cnt);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement