Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.УмнатаЛили
- {
- class Program
- {
- static void Main(string[] args)
- {
- int liLyYears = int.Parse(Console.ReadLine());
- decimal priceForLaundry = decimal.Parse(Console.ReadLine());
- decimal priceForToy = decimal.Parse(Console.ReadLine());
- decimal moneySaved = 0;
- int moneySavedCounter = 0;
- int toyCounter = 0;
- decimal result = 0;
- List<decimal> totalMoney = new List<decimal>();
- decimal brothertakesMoney = 0;
- for (int years = 1; years <= liLyYears; years++)
- {
- if (years % 2 == 0)
- {
- moneySaved += 10;
- brothertakesMoney++;
- totalMoney.Add(moneySaved);
- moneySavedCounter++;
- }
- else
- {
- toyCounter++;
- }
- }
- result = (totalMoney.Sum() + toyCounter * priceForToy- brothertakesMoney*1);
- if (result >= priceForLaundry)
- {
- Console.WriteLine("Yes! {0:F2}", result - priceForLaundry);
- }
- else
- {
- Console.WriteLine("No! {0:F2}", priceForLaundry - result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement