【发布时间】:2013-11-17 20:14:57
【问题描述】:
问题:
是否可以用 21,19 和 37 组成一个整数(比如 N)?
a. N will be provided as input
b. You can use only these three numbers: 27,19,37
c. Only multiplication, addition, repetition and replacement are allowed
例如:
Input: 24, Output: not possible
Input: 94, Output: possible - 94 = 19*3 + 37
我的查询:
- 你能帮我完成这个任务,展示 DP / Div & Con / Greedy 的路径吗?
- 我应该选择哪一个,为什么不选择其他(在这种情况下)?
-
如果您能更灵活一点地解释 DP / Greedy / Div & Con 方程并解释您的思维过程,我将不胜感激。
例如,在最长公共子序列中,我们使用以下内容://assuming X[i.....m] and Y[j.....n] LCS(i,j) = { 0 , when i = m or j=n Max { LCS(i, j+1) , LCS(i+1, j) } when X[i] ≠ Y[j] 1+ LCS(i+1,j+1) when X[i] == Y[j] }
【问题讨论】:
-
我不明白这个问题。
19 + 19 - 37 = 1。您可以重复该模式以生成您想要的每个数字 (N = 2 * N * 19 - N * 37)。你能明确允许的操作吗? -
@Heuster 减法似乎不允许(我不确定“重复”和“替换”在这里应该是什么意思)。
标签: algorithm dynamic-programming greedy