Aliendreamer

Smart Lili

Feb 15th, 2017
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 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 issue14LiliPodaruk
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. // age of Lili
  15. double Price = double.Parse(Console.ReadLine());//cena na ureda
  16. double ToyPrice =double.Parse(Console.ReadLine());//cena na edinichna igrachka
  17. double gift = 0; //edinichen podaruk suma
  18. double totalsum = 0; // obshti pari
  19. double toy=0; //obsto igrachki
  20. for(int i=1;i<=n;i++)
  21. {
  22. // for even year!
  23. if(i%2==0)
  24. {
  25. gift=(((10*i)/2)-1);
  26. totalsum+=gift;
  27.  
  28. }
  29. else
  30. {
  31.  
  32. toy +=1;
  33.  
  34. }
  35.  
  36. }
  37. double Toysum = toy * ToyPrice;
  38. double Total = Toysum + totalsum;
  39.  
  40. if (Total >= Price)
  41. {
  42. Console.WriteLine("Yes! {0:f2}",Math.Abs(Total-Price));
  43. }
  44. else
  45. {
  46. Console.WriteLine("No!{0:f2}",Math.Abs(Price-Total));
  47. }
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment