grach

2016_April_24 Smart Lili

Aug 11th, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.                    
  3. public class Program
  4. {
  5.     public static void Main()
  6.     {
  7.         int N = int.Parse(Console.ReadLine());
  8.         var laundryPrice = double.Parse(Console.ReadLine());
  9.         var toyPrice = int.Parse(Console.ReadLine());
  10.        
  11.         var deposit = 0;
  12.         var moneyFromToys = 0;
  13.         var money = 10;
  14.        
  15.         for (int i=1; i<=N;i++)
  16.         {
  17.             if (i%2 == 0)
  18.             {
  19.              deposit += money;
  20.              deposit-=1;
  21.              money+=10;        
  22.             }
  23.             else
  24.             {
  25.                 moneyFromToys+=toyPrice;
  26.             }
  27.         }
  28.        
  29.         var total = deposit + moneyFromToys;
  30.        
  31.         if(total>=laundryPrice)
  32.         {
  33.             Console.WriteLine("Yes! {0:f2}",total-laundryPrice);
  34.         }
  35.         else
  36.         {
  37.             Console.WriteLine("No! {0:f2}", laundryPrice-total);
  38.         }
  39.        
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment