{
  "type": "code_options",
  "author": "csdn.net",
  "source": "solution.md",
  "exercise_id": "c9741339e3e148d8bb36f4dedc4ee64e",
  "keywords": "算法高阶,数论算法,算法问题选编,整数的因子分解",
  "title": "不喜欢带钱的小C",
  "desc": [
    {
      "content": "\n题目描述：\n小C不喜欢带钱，有一次竟被他碰上了一家不能使用移动支付（也不能找钱）的神秘商店。请问小C至少准备多少张RMB才能恰好支付n元。RMB的面额有100元，50元，20元，10元，5元，1元。\n输入格式：\n输入一个整数n\n输出格式：\n最少带几张。\n样例输入1：\n50\n样例输出1：\n1\n约定：\n1<=n<=100",
      "language": "markdown"
    }
  ],
  "answer": [
    {
      "content": "",
      "language": "cpp"
    }
  ],
  "prepared": [
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ],
    [
      {
        "content": "",
        "language": "cpp"
      }
    ]
  ],
  "template": {
    "content": "#include <iostream>\nusing namespace std;\nint solve(int tar, int * meta, int metan, int * seed = NULL, int seedn = 0)\n{\n\tif (tar == 0)\n\t{\n\t\treturn seedn;\n\t}\n\tint min = -1;\n\tint m;\n\tint * seed1 = new int[seedn + 1];\n\tif (seed)\n\t\tmemcpy(seed1, seed, sizeof(int) * seedn);\n\tfor (int i = 0; i < metan; i++)\n\t{\n\t\tif (meta[i] <= tar)\n\t\t{\n\t\t\tseed1[seedn] = meta[i];\n\t\t\tm = solve(tar - meta[i], meta, metan, seed1, seedn + 1);\n\t\t\tif (m != -1 && (min == -1 || min > m))\n\t\t\t\tmin = m;\n\t\t\tbreak;\n\t\t}\n\t}\n\tdelete[] seed1;\n\treturn min;\n}\nint main()\n{\n\tint arr[] = { 100, 50, 20, 10, 5, 1 };\n\tint n = 6;\n\tint total;\n\tcin >> total;\n\tint result = solve(total, arr, n);\n\tcout << result << endl;\n\treturn 0;\n}",
    "language": "cpp"
  },
  "node_id": "dailycode-f5bede05c3a2454090a4bccc0479462f",
  "license": "csdn.net",
  "created_at": 1637894158,
  "topic_link": "https://bbs.csdn.net/topics/600469951"
}