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.Smart_Lili
- {
- class SmartLili
- {
- static void Main(string[] args)
- {
- int years = int.Parse(Console.ReadLine());
- double price = double.Parse(Console.ReadLine());
- int toyPrice = int.Parse(Console.ReadLine());
- var brother = 0;
- var toy = 0;
- var toySum = 0;
- double sum = 0;
- var count = 0;
- double result = 0;
- for (int i = 1; i <= years; i++)
- {
- if (i % 2 == 0)
- {
- count = 10 * ((i+1)/2);
- sum = sum + count;
- brother++;
- }
- else
- {
- toy++;
- }
- }
- toySum = toyPrice * toy;
- sum = sum + toySum - brother;
- result = Math.Abs(sum - price);
- if (sum >= price)
- {
- Console.WriteLine("Yes! {0:f2}",result);
- }
- else
- {
- Console.WriteLine("No! {0:f2}", result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement