Advertisement
sider93

Smart Lili

May 12th, 2016
352
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 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.Smart_Lili
  8. {
  9. class SmartLili
  10. {
  11. static void Main(string[] args)
  12. {
  13. int years = int.Parse(Console.ReadLine());
  14. double price = double.Parse(Console.ReadLine());
  15. int toyPrice = int.Parse(Console.ReadLine());
  16. var brother = 0;
  17. var toy = 0;
  18. var toySum = 0;
  19. double sum = 0;
  20. var count = 0;
  21. double result = 0;
  22.  
  23. for (int i = 1; i <= years; i++)
  24. {
  25. if (i % 2 == 0)
  26. {
  27. count = 10 * ((i+1)/2);
  28. sum = sum + count;
  29. brother++;
  30. }
  31. else
  32. {
  33. toy++;
  34. }
  35. }
  36. toySum = toyPrice * toy;
  37. sum = sum + toySum - brother;
  38. result = Math.Abs(sum - price);
  39. if (sum >= price)
  40. {
  41. Console.WriteLine("Yes! {0:f2}",result);
  42. }
  43. else
  44. {
  45. Console.WriteLine("No! {0:f2}", result);
  46. }
  47. }
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement