我有关于动态编程的问题.这是一个最短的路径问题.前提是我需要帮助一个"朋友"为最便宜的平铺编写一个程序,他可以用它来建立一个通往他棚屋的路径.变量D(到棚屋的距离),可以是1 <= D <5000,可以有N个类型的瓦片,因此1 <= N <= 5000,对于每个"N"瓦片,可以有一个长度,L使得1 <= L <= 5000,并且成本,C使得1 <= C <= 100.(该程序的用户将遵循上面列出的约束).我知道这是一个最短的路径问题,但我无法弄清楚如何启动图表.我正在考虑制作一个带有距离和瓷砖类型的二维数组但是反过来考虑.我正在粘贴下面的代码,它适用于错误检查的测试用例,但不包括它.如果有人可以向我提供关于我做错了什么的暗示,或者提示如何启动图表,或者只是告诉我我的方法不合适,那就太棒了.我没有使用递归,因为我希望这个程序有效运行,这就是我想使用动态编程的原因.
#include <iostream>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <limits.h>
#include <cstdio>
using namespace std;
int cheapestTiling(int dist, int numtiles, int A[], int B[]){
//distance to the shed
int shedDistance = dist;
//number of types of tiles used
int numberTiles = numtiles;
//make new arrays for the costs and lengths of each tiles
int LengthTile[numberTiles];
int PriceTile[numberTiles];
int costPerSize[numberTiles];
//min length, min price
int …Run Code Online (Sandbox Code Playgroud)