资源简介
动态规划,要求:现有硬币n枚。其价值为v(1,q,q^2……q^n),且每枚硬币重量为一,求价值为Y且重量最小的硬币集合
时间复杂度为O(n*v)
代码片段和文件信息
#include
using namespace std;
#define P 3
#define N 15
#define D 1800
int main() {
int distance[N];
distance[0] = 1;
for (int i = 1; i < N; i++)
distance[i] = distance[i - 1] * P;
int barrel = 0; int number = 0; int flag[N];
int j = 0;
for (int i = 0; i < N; i++) {
if (barrel + distance[i] <= D) {
barrel += distance[i];
}
else {
flag[j++] = i;
barrel = 0;
}
}
system(“pause“);
}
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-05-09 17:52 Algorithim_lab03_02\.vs\
目录 0 2019-05-09 17:52 Algorithim_lab03_02\.vs\Algorithim_lab03_02\
目录 0 2019-05-09 17:52 Algorithim_lab03_02\.vs\Algorithim_lab03_02\v15\
文件 31744 2019-04-29 19:10 Algorithim_lab03_02\.vs\Algorithim_lab03_02\v15\.suo
文件 5083136 2019-04-29 19:10 Algorithim_lab03_02\.vs\Algorithim_lab03_02\v15\Browse.VC.db
目录 0 2019-05-09 17:52 Algorithim_lab03_02\.vs\Algorithim_lab03_02\v15\ipch\
目录 0 2019-05-09 17:52 Algorithim_lab03_02\.vs\Algorithim_lab03_02\v15\ipch\AutoPCH\
目录 0 2019-05-09 17:52 Algorithim_lab03_02\.vs\Algorithim_lab03_02\v15\ipch\AutoPCH\5c6ba1fe0894aff6\
文件 30605312 2019-04-29 14:43 Algorithim_lab03_02\.vs\Algorithim_lab03_02\v15\ipch\AutoPCH\5c6ba1fe0894aff6\源.ipch
文件 1471 2019-04-15 14:54 Algorithim_lab03_02\Algorithim_lab03_02.sln
目录 0 2019-05-09 17:52 Algorithim_lab03_02\Algorithim_lab03_02\
文件 5954 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Algorithim_lab03_02.vcxproj
文件 948 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Algorithim_lab03_02.vcxproj.filters
文件 165 2019-04-15 14:54 Algorithim_lab03_02\Algorithim_lab03_02\Algorithim_lab03_02.vcxproj.user
目录 0 2019-05-09 17:52 Algorithim_lab03_02\Algorithim_lab03_02\Debug\
目录 0 2019-05-09 17:52 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorith.1D5C2967.tlog\
文件 235 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorith.1D5C2967.tlog\Algorithim_lab03_02.lastbuildstate
文件 784 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorith.1D5C2967.tlog\CL.command.1.tlog
文件 18854 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorith.1D5C2967.tlog\CL.read.1.tlog
文件 752 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorith.1D5C2967.tlog\CL.write.1.tlog
文件 1406 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorith.1D5C2967.tlog\li
文件 3994 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorith.1D5C2967.tlog\li
文件 736 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorith.1D5C2967.tlog\li
文件 138 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\Algorithim_lab03_02.log
文件 150528 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\vc141.idb
文件 339968 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\vc141.pdb
文件 34614 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\Debug\源.obj
文件 452 2019-04-15 15:03 Algorithim_lab03_02\Algorithim_lab03_02\源.cpp
目录 0 2019-05-09 17:52 Algorithim_lab03_02\Debug\
文件 38400 2019-04-15 15:03 Algorithim_lab03_02\Debug\Algorithim_lab03_02.exe
文件 322356 2019-04-15 15:03 Algorithim_lab03_02\Debug\Algorithim_lab03_02.ilk
............此处省略1个文件信息
- 上一篇:MultiWii MWC代码解读
- 下一篇:password.txt
评论
共有 条评论