Advertisement
Guest User

Untitled

a guest
Jun 9th, 2014
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.17 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4.  
  5.  
  6. class Program
  7. {
  8. static void Main()
  9. {
  10. int sum = int.Parse(Console.ReadLine());
  11. int dif = int.Parse(Console.ReadLine());
  12. int digSum = 0;
  13. int abc = 0;
  14. int def = 0;
  15. int ghi = 0;
  16. bool noResult = true;
  17. for (int a = 1; a < 8; a++)
  18. {
  19. for (int b = 1; b < 8; b++)
  20. {
  21. for (int c = 1; c < 8; c++)
  22. {
  23. for (int d = 1; d < 8; d++)
  24. {
  25. for (int e = 1; e < 8; e++)
  26. {
  27. for (int f = 1; f < 8; f++)
  28. {
  29. for (int g = 1; g < 8; g++)
  30. {
  31. for (int h = 1; h < 8; h++)
  32. {
  33. for (int i = 1; i < 8; i++)
  34. {
  35. digSum = a + b + c + d + e + f + g + h + i;
  36. if (digSum == sum)
  37. {
  38. abc = a * 100 + b * 10 + c;
  39. def = d * 100 + e * 10 + f;
  40. ghi = g * 100 + h * 10 + i;
  41. if ((abc <= def) && (def - abc == ghi - def) && (def - abc == dif))
  42. {
  43. Console.WriteLine("{0}{1}{2}", abc, def, ghi);
  44. noResult = false;
  45. }
  46. }
  47. }
  48. }
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
  56. if (noResult)
  57. {
  58. Console.WriteLine("No");
  59. }
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement