Advertisement
KeepCoding

Poke Mon

Apr 11th, 2018
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 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 Problem_1.Poke_Mon
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int N = int.Parse(Console.ReadLine());      //N
  14.             int M = int.Parse(Console.ReadLine());       //M
  15.             int Y = int.Parse(Console.ReadLine());  //Y
  16.            
  17.             bool isAccurateValue = true;
  18.             if (Y == 0 || Y == 1)
  19.             {
  20.                 isAccurateValue = false;
  21.             }
  22.  
  23.             int originalValueDividedBy2 = 0;
  24.             if (N % 2 == 0) //we need EXACTLY 50% of the original value
  25.             {
  26.                 originalValueDividedBy2 = N / 2;
  27.             }
  28.             int targetsPoked = 0;
  29.  
  30.             while (N >= M)
  31.             {
  32.               if (N == originalValueDividedBy2 && isAccurateValue)
  33.                 {
  34.                     N /= Y;
  35.                     continue;
  36.                 }
  37.              
  38.                 N -= M;
  39.                 targetsPoked++;
  40.             }
  41.  
  42.             Console.WriteLine(N);
  43.             Console.WriteLine(targetsPoked);
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement