Advertisement
noname1994

Untitled

Dec 15th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 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 NumberGenerator
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int m = int.Parse(Console.ReadLine());
  14. int n = int.Parse(Console.ReadLine());
  15. int l = int.Parse(Console.ReadLine());
  16. int spec = int.Parse(Console.ReadLine());
  17. int control = int.Parse(Console.ReadLine());
  18. bool isFound = false;
  19.  
  20. for (int a1 = m; a1 >= 1; a1--)
  21. {
  22. if (isFound)
  23. {
  24. break;
  25. }
  26. for (int a2 = n; a2 >= 1; a2--)
  27. {
  28. if (isFound)
  29. {
  30. break;
  31. }
  32. for (int a3 = l; a3 >= 1; a3--)
  33. {
  34. int currentNumber = a1 * 100 + a2 * 10 + a3;
  35. if (currentNumber % 3 == 0)
  36. {
  37. spec += 5;
  38. }
  39. else if (currentNumber % 10 == 5)
  40. {
  41. spec -= 2;
  42. }
  43. else if (currentNumber % 2 == 0)
  44. {
  45. spec = spec * 2;
  46. }
  47. if (spec >= control)
  48. {
  49. Console.WriteLine("Yes! Control number was reached! Current special number is {0}.", spec);
  50. isFound = true;
  51. break;
  52. //return;
  53. }
  54. }
  55. }
  56. }
  57. if (!isFound)
  58. {
  59. Console.WriteLine("No! {0} is the last reached special number.", spec);
  60. }
  61. }
  62. }
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement