zornitza_gencheva

NineDigitNumbers_full_operated

Apr 18th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.70 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 NineDigitNumbers
  8. {
  9. class NineDigitNumbers
  10. {
  11. static void Main(string[] args)
  12. {
  13. uint sum = uint.Parse(Console.ReadLine());
  14. uint diff = uint.Parse(Console.ReadLine());
  15.  
  16. int flag = 0;
  17.  
  18. for (int a = 1; a <= 7; a++)
  19. {
  20. for (int b = 1; b <= 7; b++)
  21. {
  22. for (int c = 1; c <= 7; c++)
  23. {
  24. for (int d = 1; d <= 7; d++)
  25. {
  26. for (int e = 1; e <= 7; e++)
  27. {
  28. for (int f = 1; f <= 7; f++)
  29. {
  30. int first = int.Parse(a.ToString() + b.ToString() + c.ToString());
  31. int second = int.Parse(d.ToString() + e.ToString() + f.ToString());
  32.  
  33. if (second - first == diff)
  34. {
  35. for (int g = 1; g <= 7; g++)
  36. {
  37. for (int h = 1; h <= 7; h++)
  38. {
  39. for (int i = 1; i <= 7; i++)
  40. {
  41. if (a + b + c + d + e + f + g + h + i == sum)
  42. {
  43. int third = int.Parse(g.ToString() + h.ToString() + i.ToString());
  44.  
  45. if (third - second == diff && second - first == diff)
  46. {
  47. Console.WriteLine("{0}{1}{2}{3}{4}{5}{6}{7}{8}", a, b, c, d, e, f, g, h, i);
  48. flag++;
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. }
  60. }
  61.  
  62. if (flag == 0)
  63. {
  64. Console.WriteLine("No");
  65. }
  66. }
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment