当前位置:首页 >> 学科竞赛 >>

holstein


【题目描述】

Healthy Holsteins
Burch & Kolstad Farmer John prides himself on having the healthiest dairy(乳品的) cows in the world. He knows the vitamin(维生素) content for one scoop(勺) of each feed type and the minimum(最小的) daily vitamin requirement for the cows. Help Farmer John feed his cows so they stay healthy while minimizing(使减到最少) the number of scoops that a cow is fed. Given the daily requirements of each kind of vitamin that a cow needs, identify(确定) the smallest combination(结合) of scoops of feed a cow can be fed in order to meet at least the minimum vitamin requirements. Vitamins are measured in integer(整数) units. Cows can be fed at most one scoop of any feed type. It is guaranteed(保证) that a solution(解决方案) exists for all contest(竞赛) input(投入) data. 【我的思路】 DFS 把所有的情况枚举一遍,按照组合数的搜索方法。 【code】 { ID:yxy07015 PROG:holstein LANG:PASCAL } var n,m,i,j,v,min:integer; a:array[1..25] of integer; b,minb:array[0..15] of integer; map:array[1..15,1..25] of integer; function check:boolean; begin for v:=1 to n do if a[v]>0 then exit(false); exit(true); end; procedure dfs(k:integer); var i:integer; begin if check then begin if k-1<min then begin min:=k-1; minb:=b; end; end else for i:=b[k-1]+1 to m do begin

b[k]:=i; for j:=1 to n do dec(a[j],map[i,j]); dfs(k+1); b[k]:=0; for j:=1 to n do inc(a[j],map[i,j]); end; end; begin assign(input,'holstein.in'); reset(input); assign(output,'holstein.out'); rewrite(output); readln(n); for i:=1 to n do read(a[i]); readln(m); for i:=1 to m do for j:=1 to n do read(map[i,j]); min:=$7f; b[0]:=0; dfs(1); write(min,' '); for v:=1 to min-1 do write(minb[v],' '); writeln(minb[min]); close(input); close(output); end. Executing... Test 1: TEST OK [0.003 secs, 276 KB] Test 2: TEST OK [0.003 secs, 276 KB] Test 3: TEST OK [0.000 secs, 276 KB] Test 4: TEST OK [0.003 secs, 276 KB] Test 5: TEST OK [0.000 secs, 276 KB] Test 6: TEST OK [0.003 secs, 276 KB] Test 7: TEST OK [0.003 secs, 276 KB] Test 8: TEST OK [0.005 secs, 276 KB] Test 9: TEST OK [0.011 secs, 276 KB] Test 10: TEST OK [0.030 secs, 276 KB] All tests OK.


相关文章:
水牛奶的营养价值
This article will compare the o nutrients f buffalo milk and Holstein milk and human breast milk, and state the nutrient value of buffalo milk use ...
德国基本法
(Sarrland)、萨克森(Sachsen)、萨克森-安哈特(Sachsen-Anhalt)、 什勒斯维希-霍尔斯坦(Schleswig-Holstein)及图林根(Thueringen)各邦之德意 志人民依自由决定完成德国...
关于英美的地名
Angle 的原义是"钩子",因为这个民族是从德国西北部 Schleswig-Holstein 地方一块钩形半岛(德文 Angeln)到不列颠来的。这名称可能是先被外人(如罗马人)叫起来的,...
第四纪冰期_图文
周口店第一地点北京人化石层及北京人洞穴底部泥砾层的孢粉组合研 究结果,证明周口店北京人化石层可以和赫尔斯坦(Holsteinian)间冰期对比,用 裂变径迹法测得第十层...
盘点德国不收学费的大学
1、北威州 Nordrhein-Westfalen 代表为亚琛工大、杜塞、科隆、 明斯特等大学 2、 石荷州 Schleswig-Holstein 代表为基尔大学 3、 勃兰登堡州 Brandenburg 代表为...
德意志联邦共和国基本法
(Sarrland)、萨克森 (Sachsen)、萨克森-安哈特(Sachsen-Anhalt)、什勒斯维希-霍尔斯坦(Schleswig-Holstein) 及图林根(Thueringen)各邦之德意志人民依自由决定完成德国...
特殊名称骨折及骨科评分--汇总速记
Holstein—Lewis 骨折】肱骨远端 1/3 骨折伴桡神经嵌压。 【Posadas 骨折】经髁的肱骨骨折,伴有骨折碎块向前移位,以及因双髁骨折造成尺桡骨的 脱位。【Kocher ...
USACO代码解析Healthy Holsteins (holstein)
USACO代码解析Healthy Holsteins (holstein)_计算机软件及应用_IT/计算机_专业资料。USACO代码解析Healthy Holsteins (holstein)使喂给牛的饲料的种数最少。 给出牛...
德国点心(德语)
Kirsch-Gelee (Schleswig-Holstein) 1 Glas entsteinte Sauerkirschen (Abtropfgewicht 370g) 2 EL Zucker 1/4 TL gemahlener Zimt 1 Prise gemahlene Nel...
How many megawatts of electricity were added in 199...
In the windy northern state of Schleswig Holstein, wind now pro vides 15 percent of the electricity.最新上传套卷2016年高考模拟 理数 2015年高考真题 理数...
更多相关标签: