Advertisement
braveheart1989

УмнатаЛили

Apr 25th, 2016
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 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 _04.УмнатаЛили
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int liLyYears = int.Parse(Console.ReadLine());
  14. decimal priceForLaundry = decimal.Parse(Console.ReadLine());
  15. decimal priceForToy = decimal.Parse(Console.ReadLine());
  16. decimal moneySaved = 0;
  17. int moneySavedCounter = 0;
  18. int toyCounter = 0;
  19. decimal result = 0;
  20. List<decimal> totalMoney = new List<decimal>();
  21. decimal brothertakesMoney = 0;
  22. for (int years = 1; years <= liLyYears; years++)
  23. {
  24. if (years % 2 == 0)
  25. {
  26. moneySaved += 10;
  27. brothertakesMoney++;
  28. totalMoney.Add(moneySaved);
  29. moneySavedCounter++;
  30. }
  31. else
  32. {
  33. toyCounter++;
  34. }
  35. }
  36. result = (totalMoney.Sum() + toyCounter * priceForToy- brothertakesMoney*1);
  37. if (result >= priceForLaundry)
  38. {
  39. Console.WriteLine("Yes! {0:F2}", result - priceForLaundry);
  40. }
  41. else
  42. {
  43. Console.WriteLine("No! {0:F2}", priceForLaundry - result);
  44. }
  45. }
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement