发帖数: 1 | 1 http://rosettacode.org/wiki/24_game/Solve#C
改一下就行了。这是输入4个的,可以改成输入3个的。
6 17 3 7: No solution
……
#include
#include
#include
#define n_cards 4
#define solve_goal 29
#define max_digit 9
typedef struct { int num, denom; } frac_t, *frac;
typedef enum { C_NUM = 0, C_ADD, C_SUB, C_MUL, C_DIV } op_type;
typedef struct expr_t *expr;
typedef struct expr_t {
op_type op;
expr left, right;
int value;
} expr_t;
void show_expr(expr e, op_type prec, int is_r... 阅读全帖 |
|
j**7 发帖数: 143 | 2 public static int minCoinsFor(int[] denom, int total) {
int[][] choice = new int[denom.length + 1][total + 1];
int[][] DP = new int[denom.length + 1][total + 1];
DP[denom.length][0] = 0;
for (int i = 1; i <= total; i++) {
DP[denom.length][i] = -1;
}
for (int i = denom.length - 1; i >= 0; i--) {
for (int j = 0; j <= total; j++) {
int min = -1;
for (int k = 0; k * denom[i] <= j; k++) {
... 阅读全帖 |
|
m***n 发帖数: 2154 | 3 一个简单的递归算法
public static int numberofways(int [] denom, int start, int amount, String
prefix) {
int total=0;
if(start>denom.length-1) return 0;
if(amount==0) {
System.out.println(prefix+" "+ amount +":"+ denom[start]);
return 1;
}
//if(denom[start]==amount) return 1;
if(start==denom.length-1) {
System.out.println(prefix+" "+ amount +":"+ denom[start]);
return 1;
};
for(int i=0;... 阅读全帖 |
|
s******d 发帖数: 61 | 4 可以多余2个数,这题DP怎么做啊.......
还有
最经典的DP coin问题, careercup上是求所有可能的次数
public static int makeChange(int n, int denom){
int next_denom=0;
switch(denom){
case 25:
next_denom=10;
break;
case 10:
next_denom=5;
break;
case 5:
next_denom=1;
break;
case 1:
return 1;
}
int ways=0;
for(int i=0;i*denom
ways+=makeChange(n-i*denom,next_denom);
}
return ways;
}
如果要求print 所有的pair应该如果改code呢?
多谢多谢 |
|
x****r 发帖数: 99 | 5 c#的解,请帮我看看对不对,谢谢
测试过{3, 5, 7}和32 的时候答案是6
public static void findDenominations(int[] denom, int Value){
int[] DP = new int[Value + 1];
DP[0] = 0;
for (int i = 1; i <= Value ++i){
int min = 9999;
for (int j = 0; j < denom.Length; ++j){
int prev = Value - denom[j];
if (prev > -1 && DP[prev] < min)
min = DP[prev];
}
DP[i] = min + 1;
}
Console.WriteLine(DP[Value]);
} |
|
f******5 发帖数: 11 | 6 来自主题: Computation版 - test It compiles!!
#include
using namespace std;
int moneyChange(int *money, int len, int i);
int main(void)
{
int len=11;
int money[]={0,1,0,0,0,0,0,0,0,0,0};
int amount=10;
moneyChange(money, 11, 10);
for (int i=0;i
cout<
system("pause");
return 0;
}
int moneyChange(int *money, int , int i){
int min_temp=i;
int denom[3]={1, 3, 4};
if (i==0... 阅读全帖 |
|
a*u 发帖数: 97 | 7 You are given some denominations of coins in an array (int denom[])and
infinite supply of all of them. Given an amount (int amount), find the
minimum number of coins required to get the exact amount
for example, 面值数组 denom = {7, 5, 3}, target amount = 32, minimum number
of coins needed is 6 (2x7 + 3x5 + 1x3 = 32)
想到的只有greedy。。。有没有优雅一点的解法? |
|
s********e 发帖数: 893 | 8 用oracle好几年了,最近开始想系统学习一下才知道以前用的一个oracle产品自己产生
的materialized view也是denomalization的一种。还有我们经常用的把multiple rows
convert到同一行的multiple columns也是denomilization。从Beijing MM和yhangw那
学到的partion by后,发现以前需要好多步才能做到的简单几步就做到了。数据每天白
天更新,我们晚上就run script denomalize 一下生成很多table。大牛说这就是我们
自己的data warehouse。 |
|
|
m***n 发帖数: 2154 | 10 算法就是把硬币排序, 从大的排起。。
最多包含 x= amount/denom[k] 个 k硬币, 类似于一个BFS 的N-ary tree 搜索了 |
|
G*******s 发帖数: 4956 | 11 我們是誰?-- 福音派的身份
WHO ARE WE? The Evangelical's Identity
I.我們是基督新教PROTESTANTISM: We are Protestants
1517 馬丁路德 - 宗教改革
Martin Luther - The Protestant Reformation
天主教 vs. 基督教 (基督新教)之別﹕ Roman Catholicism vs. Protestantism:
1 . 至高權威﹕《聖經》?或《聖經》 + 教會的教導權威(教皇+會議)?
Highest authority: Bible? Or the Bible+church's teaching authority (Pope+ co
uncils)? The magisterium of the church = the church's teaching authority
2 . 耶穌基督救贖功勞如何獲得﹕只藉信心?或信心+行為(聖禮)?
How to receive the benefits of the redemption accomplish... 阅读全帖 |
|
y****9 发帖数: 144 | 12 Also with a 9m table containing age and agecode column, seems this is a
violation of 3 normal form for table design.
An alternative design may be creating a look up table with two column age
and agecode. the original table only includes a col called date of birth,
the acutual aga could be computed - in this design you don't need to do such
update in the first place. But i am just speaking in general, maybe your
application is some kind of data warehousing, denomalization could be valid
.. |
|
l******t 发帖数: 660 | 13 你的意思是query的时候做 data base denomalization吧? 就是join fact table和
dimension table成一个大的data set, 这个都是query time或者 单独一个view,要
是都pre populate成为一个大table, 就失去了star schema的意义 |
|
l******t 发帖数: 660 | 14 你的意思是query的时候做 data base denomalization吧? 就是join fact table和
dimension table成一个大的data set, 这个都是query time或者 单独一个view,要
是都pre populate成为一个大table, 就失去了star schema的意义 |
|
c******o 发帖数: 1277 | 15 shard就没事了。最后要是太大数据量,还不是就一条路?
trade consistence for scalability, denomalization |
|
x**u 发帖数: 239 | 16 以前都是设定的特征阻抗50ohm,现在是要仿一段线的特征
阻抗,不知道hfss里面怎么设置阿,有人说用什么post processing
里面denomalize,但貌似不行,不知道有没有人能给点意见怎么操作? |
|
a*****m 发帖数: 4745 | 17 Anyone how to deal with this problem?
When I try to specify the NSR matrix in deconvwnr(blurred, psf, NSR) to
perform
deconvolution, according to the help file, NSR can be a scalar or an array of
the
same size as blurred image. However, when i tried to use NSR as an array of
the same
size as blurred image, there poped up an error:
??? Error using ==> unknown
Matrix dimensions must agree.
Error in ==> deconvwnr at 120
Denom = abs(otf(nojunk(:))).^2 + K;
I tried that with my image file and the exa |
|
a*****m 发帖数: 4745 | 18 Can anyone help me with this problem?
When I try to specify the NSR matrix in deconvwnr(blurred, psf, NSR) to
perform
deconvolution, according to the help file, NSR can be a scalar or an array of
the
same size as blurred image. However, when i tried to use NSR as an array of
the same
size as blurred image, there poped up an error:
??? Error using ==> unknown
Matrix dimensions must agree.
Error in ==> deconvwnr at 120
Denom = abs(otf(nojunk(:))).^2 + K;
I tried that with my image file and the exa |
|