{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "e7452e4cc4cf410c94611ff2756adcbd",
  "keywords": "图算法,算法高阶,图的表示,基本的图算法",
  "title": "六角填数",
  "desc": [
    {
      "content": "\n<p>![图片说明](https://img-ask.csdn.net/upload/202006/14/1592104139_240178.png)\n六角填数\n题目描述\n如下图所示六角形中，有12个点，依次填入1~12的数字，使得每条直线上的数字之和都相同。其中，已经替你填好了点1，2，3的数字，请你计算其他位置所代表的数字是多少？\n输入\n输入仅一行，以空格隔开，分别表示已经填好的点1,2,3的数字。\n输出\n输出仅一行，以空格隔开，分别表示所有位置所代表的数字。\n样例输入：\n1 8 2\n样例输出：\n1 8 2 9 7 11 10 12 3 5 6 4</p>",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include <iostream>\n#include <cmath>\n#include <cstdio>\n#include <cstring>\nusing namespace std;\n#define eps 10e-10\n#define N 15\nint a[N];\nbool vis[N];\nvoid dfs(int x){\n\tif(x == 1 || x == 2 || x == 3){\n\t\tdfs(x+1);\n\t\treturn ;\n\t}\n\tif(x > 12){\n\t\tint t[6];\n\t\tt[0] = a[1] + a[3] + a[6] + a[8];\n\t\tt[1] = a[1] + a[4] + a[7] + a[11];\n\t\tt[2] = a[2] + a[3] + a[4] + a[5];\n\t\tt[3] = a[2] + a[6] + a[9] + a[12];\n\t\tt[4] = a[8] + a[9] + a[10] + a[11];\n\t\tt[5] = a[12] + a[10] + a[7] + a[5];\n\t\tfor(int i = 1; i < 6; ++i){\n\t\t\tif(t[i] != t[i-1])return ;\n\t\t}\n\t\tfor (int i = 1; i <= 12; i++) cout << a[i] << \" \";\n\t\treturn ;\n\t}\n\tfor(int i = 1;i < 13; ++i){\n\t\tif(!vis[i]){\n\t\t\tvis[i] = 1;\n\t\t\ta[x] = i;\n\t\t\tdfs(x+1);\n\t\t\tvis[i] = 0;\n\t\t}\n\t}\n}\nint main(){\n\tmemset(vis,0,sizeof(vis));\n\tcin >> a[1];\n\tvis[a[1]] = 1;\n\tcin >> a[2];\n\tvis[a[2]] = 1;\n\tcin >> a[3];\n\tvis[a[3]] = 1;\n\tdfs(1);\n\treturn 0;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-70c36c9a7d99475c87b427df4b2fe285",
  "license": "csdn.net",
  "created_at": 1637894159,
  "topic_link": "https://bbs.csdn.net/topics/600470159"
}