Redian新闻
>
Sprint prepaid手机拿回国能用吗
avatar
Sprint prepaid手机拿回国能用吗# Apple - 家有苹果
a*o
1
Suppose you are given a function void NumberofSum(int n) , write a code such
that will print all the numbers that will sum up to n.
Input n Output
1 {1}
2 {(1,1),(2)}
3 {(1,1,1),(1,2),(3)}
4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!
avatar
p*e
2
大概高一层楼的样子的,代理说栽排树挡一下就可以了,不知道行不行?
后院的yard也是从高向低,是个小土坡的样子,不知道会不会容易积水?屋主做了
french drain,不知道有没有帮助?
请大家提提意见,谢谢啦!
avatar
s*r
3
【 以下文字转载自 WaterWorld 讨论区 】
发信人: sgrastar (Theodore), 信区: WaterWorld
标 题: The title of the thesis does not matter
发信站: BBS 未名空间站 (Sun Oct 17 16:35:28 2010, 美东)
One sunny day a rabbit came out of her hole in the ground to enjoy the fine
weather. The day was so nice
that she became careless and a fox sneaked up behind her and caught her.
"I am going to eat you for lunch!", said the fox.
"Wait!", replied the rabbit, "You should at least wait a few days."
"Oh yeah? Why should I wait?"
"Well, I am just finishing my thesis on 'The Superiority of Rabbits over
Foxes and Wolves.'"
"Are you crazy? I should eat you right now! Everybody knows that a fox will
always win over a rabbit."
"Not really, not according to my research. If you like, you can come into my
hole and read it for yourself. If
you are not convinced, you can go ahead and have me for lunch."
"You really are crazy!" But since the fox was curious and had nothing to
lose, it went with the rabbit. The
fox never came out. A few days later the rabbit was again taking a break
from writing and sure enough, a
wolf came out of the bushes and was ready to set upon her.
"Wait!" yelled the rabbit, "you can't eat me right now."
"And why might that be, my furry appetizer?"
"I am almost finished writing my thesis on 'The Superiority of Rabbits over
Foxes and Wolves.'"
The wolf laughed so hard that it almost lost its grip on the rabbit. "Maybe
I shouldn't eat you. You really are
sick...in the head. You might have something contagious."
"Come and read it for yourself. You can eat me afterward if you disagree
with my conclusions."
So the wolf went down into the rabbit's hole...and never came out. The
rabbit finished her thesis and was
out celebrating in the local lettuce patch. Another rabbit came along and
asked, "What's up? You seem very
happy."
"Yup, I just finished my thesis."
"Congratulations. What's it about?"
"'The Superiority of Rabbits over Foxes and Wolves.'"
"Are you sure? That doesn't sound right."
"Oh yes. Come and read it for yourself."
So together they went down into the rabbit's hole. As they entered, the
friend saw the typical graduate
student abode, albeit a rather messy one after writing a thesis. The
computer with the controversial work
was in one corner. To the right there was a pile of fox bones, to the left a
pile of wolf bones. And in the
middle was a large, well fed lion.
The moral of the story: The title of your thesis doesn't matter.
The subject doesn't matter.
The research doesn't matter.
All that matters is who your advisor is.
avatar
m*y
4
据说是连Sprint自己的Post pay plan都用不了. 但是又说sprint不锁国际的,谁知道
的给说说。
谢谢!
avatar
l*r
5
不用DP吧:
假设下标从1开始:
set[1] = 1;
set[i] = {i, set[i-1] X set[1], set[i-2] X set[2], ... ,set[i/2 -1] X set[i/2+1] }
X 是Cartesian product. 结果要remove duplicate。

such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

avatar
d*e
6
心里看了觉得不舒服就不要买,第六感很灵的
avatar
a*7
7
只有苹果店买的全价无合同机才可以

【在 m***y 的大作中提到】
: 据说是连Sprint自己的Post pay plan都用不了. 但是又说sprint不锁国际的,谁知道
: 的给说说。
: 谢谢!

avatar
a*o
8
我的思路也是类似,就是 set(4)={set(3)+1}U{set(2)+2}U{set(1)+3} (U是并集的意
思), 然后remove duplicate。 不过这样复杂很高的说。 不知道有没有啥高效的方法
avatar
p*e
9
就是看了之后很喜欢。但是担心住了以后会有问题,比如说排水的问题之类的。第一次
买房,实在是没有经验。

【在 d*********e 的大作中提到】
: 心里看了觉得不舒服就不要买,第六感很灵的
avatar
z*e
10
可以用。
avatar
Z*Z
11
回溯

【在 a***o 的大作中提到】
: 我的思路也是类似,就是 set(4)={set(3)+1}U{set(2)+2}U{set(1)+3} (U是并集的意
: 思), 然后remove duplicate。 不过这样复杂很高的说。 不知道有没有啥高效的方法
: 。

avatar
t*3
12
最好买周围地势比房子低的,便于排水。前不久中西部部分地区下暴雨,不少不在洪区
的房子地下室都进水,就是周围排水来不及。
avatar
a*o
13
大侠,可以详细讲一下吗?谢谢!

【在 Z*****Z 的大作中提到】
: 回溯
avatar
p*e
14
地势高的好lot早就被抢走了。我们又很想在这个区买。
我们这里最近也下过大雨,所以我仔细地看了一下地下室,好像没有进水。不知道这样
行不行?

【在 t***3 的大作中提到】
: 最好买周围地势比房子低的,便于排水。前不久中西部部分地区下暴雨,不少不在洪区
: 的房子地下室都进水,就是周围排水来不及。

avatar
Z*Z
15
你告诉我你会做马踏棋盘和穷举排列组合,我就给你讲这个:)

【在 a***o 的大作中提到】
: 大侠,可以详细讲一下吗?谢谢!
avatar
s*d
16
你要是平原就你家最低,那你的房子不能要了。
要是丘陵就一个房子比你家高,那你房子值老钱了。
avatar
d*a
17
以前想过这道题,主要就是用递归吧。假设数组index放结果,首先就是选一个值为
index[0],剩下的index[1]到index[n]小于等于这个值,递归的时候index[0] >= index
[1] >= index[2] >= ... >= index[n].
void sum_helper(int *a, int index, int n, int max)
{
int i;

if(n == 0)
{
for(i = 0; i < index; i++)
printf("%d ", a[i]);

printf("\n");
return;
}

for(i = 1; i <= max && i <= n; i++)
{
a[index] = i;
sum_helper(a, index + 1, n - i, i);
}
}
void sum(int n)
{
int *a = (int *)malloc(sizeof(int) * n);
int max;

for(max = 1; max <= n; max++)
{
a[0] = max;
sum_helper(a, 1, n - max, max);
}
}

such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

avatar
t*3
18
这几方面要考虑:
1)滑坡的可能,考察一下地质结构;
2)暴雨排水,可以挖排水沟;
3)隐私,可以种常青树把邻居视线挡一下。
如果没大问题可以考虑。
avatar
i*e
19
subset sum 的一个变种。
一些常见面试题的答案与总结 -
http://www.ihas1337code.com

such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

avatar
q*m
20
挺好的,后有靠山,好风水呢。注意看看排水有没有问题。
avatar
x*s
21
void numberOfSum(int sum, vector v, int last)
{
if(sum == 0)
{
for (int i = 0; i < v.size(); i++)
{
cout<}
cout<return;
}
for (int i = 1; i <= sum; i++)
{
if(sum - i >= 0 && i >= last)
{
vector temp = v;
temp.push_back(i);
numberOfSum(sum-i,temp,i);
}
}
}
avatar
g*y
22
为啥后有靠山就风水号哪

【在 q********m 的大作中提到】
: 挺好的,后有靠山,好风水呢。注意看看排水有没有问题。
avatar
a*o
23
谢谢,有思路了~

【在 i**********e 的大作中提到】
: subset sum 的一个变种。
: 一些常见面试题的答案与总结 -
: http://www.ihas1337code.com
:
: such

avatar
A*l
24
递归
F(n)
{
for(i=1; ioutput(i, F(n-i));
}
当然还需要考虑重复的输出

such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

avatar
s*l
25
http://spellscroll.com/questionfull/291/
http://en.wikipedia.org/wiki/Integer_partition
http://code.activestate.com/recipes/218332-generator-for-intege
http://www.cs.sunysb.edu/~algorith/files/generating-partitions.

such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

avatar
P*x
26
递归啊

such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

avatar
z*s
27
同意。

【在 i**********e 的大作中提到】
: subset sum 的一个变种。
: 一些常见面试题的答案与总结 -
: http://www.ihas1337code.com
:
: such

avatar
a*o
28
Thank you all. Really very helpful suggestions.
avatar
b*e
29
思路是对的,就是用递归,多用个参数,就是最大的数/上限,
n_series_with_upperbound(n,k)
= UNION ( n_series_with_max(n,j) ), j=1,2,...k
n_series_with_max(n,j)
= (list j n_series_with_upbound(n-j,j)) if n>=j; EMPTY otherwise
n_series = n_series_with_upperbound(n,n).

such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

avatar
f*4
30
用DP可以解吗?用subset sum的方法一个一个解?
avatar
g*s
31
DP就是从sum(n-1)推到sum(n),对于sum(n-1)的每个解,要不然在这个解中加一个
element 1,要不把这个解中现有的each element + 1,然后trim下,去掉duplicate就
可以了
avatar
k*s
32
受到wiki上的启发, http://en.wikipedia.org/wiki/Integer_partition
wiki上是用smallest addedn is k, 我改成with m's largest addend k
// k is the maximum number of integer partition;
// m is the num of k of integer partition.
void ip_helper(int n, int k, int m, std::deque sequence) {
if (n < k*m)
return;
if (k < 1)
return;
int i, j, r = n-k*m;
for (i=0; isequence.push_back(k);
if (r == 0) {
for (i=0; istd::cout << sequence[i] << ' ';
std::cout << std::end;
return;
}
for (i=k-1; i>0; --i)
for (j=r/i; j>0; --j) {
ip_helper(r, i, j, sequence);
}
}
void ip(int n) {
std::cout << "integer partition for : " << n << std::endl;
int k,m;
std::deque sequence;
for (k=n; k>0; --k)
for (m=n/k; m>0; --m)
ip_helper(n, k, m, sequence);
}

【在 g*******s 的大作中提到】
: DP就是从sum(n-1)推到sum(n),对于sum(n-1)的每个解,要不然在这个解中加一个
: element 1,要不把这个解中现有的each element + 1,然后trim下,去掉duplicate就
: 可以了

avatar
c*n
33
就是coin 问题, coin set 从1,2,3,.... 一直到n

code such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

avatar
c*n
34
find_sum( total , remaining_coin_set, used_coin_set ) {
if ( total == 0 ) {
print_out(used_coin_set);
}
else {
use_this_coin = remaining_coin_set.pop();
more_used_coin_set = { used_coin_set }
for( sub_total = total; sub_total >= 0; sub_total -=
use_this_coin.value() ) {
find_sum( sub_total, remaining_coin_set, more_used_coin_set);
more_used_coin_set.add(use_this_coin);
}
}

code such

【在 a***o 的大作中提到】
: Suppose you are given a function void NumberofSum(int n) , write a code such
: that will print all the numbers that will sum up to n.
: Input n Output
: 1 {1}
: 2 {(1,1),(2)}
: 3 {(1,1,1),(1,2),(3)}
: 4 {(1,1,1,1),(1,1,2),(1,3),(2,2),(4)}
: 感觉上应该用DP,可是又没啥思路。请各位大侠不吝赐教!谢谢!

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。