前些天报名参加GOOGLE,第一题很简单,虽然5分钟就做出来了,但现学VB.NET ,半小时也没调试过去,确实有些恼火。最后被无情地淘汰。是否大家学VB的信心跟我一样,受到打击了?---------------------------------------- http://blog.csdn.net/northwolves/archive/2005/12/12/550613.aspx关于不定方程整数解的个数的求法 题目:整数数列 {xn} ∈[0,max] , 且 ∑xi=sum, 则这样的序列共有多少个? 方法:递归Function resultcount(ByVal n As Integer, ByVal max As Integer, ByVal sum As Integer) As Integer If n * max < sum Then resultcount = 0: Exit Function If n = 1 Then resultcount = 1 If sum = 1 Then resultcount = n If n > 1 Then Dim i As Integer, temp As Integer temp = 0 For i = 0 To max temp = temp + resultcount(n - 1, max, sum - i) Next resultcount = temp End If End Function
To province_(雍昊) 这题和那个猴子吃桃问题(每天吃0到Y个,X天吃完N个桃,Y<=N)是同样道理。 ----------------------------------- 不错,并不是很难.我在这里也不是为了讨论这个问题,只是慨叹VB的地位. 至于竞赛题,感兴趣的朋友可以看看,原题如下:Question: Problem Statement You have several identical balls that you wish to place in several baskets. Each basket has the same maximum capacity. You are given an int baskets, the number of baskets you have. You are given an int capacity, the maximum capacity of each basket. Finally you are given an int balls, the number of balls to sort into baskets. Return the number of ways you can divide the balls into baskets. If this cannot be done without exceeding the capacity of the baskets, return 0. Each basket is distinct, but all balls are identical. Thus, if you have two balls to place into two baskets, you could have (0, 2), (1, 1), or (2, 0), so there would be three ways to do this. Definition Class: FillBaskets Method: countWays Parameters: int, int, int Returns: int Method signature: int countWays(int baskets, int capacity, int balls) (be sure your method is public)Constraints - baskets will be between 1 and 5, inclusive. - capacity will be between 1 and 20, inclusive. - balls will be between 1 and 100, inclusive. Examples: 0) 2 20 2 Returns: 3 The example from the problem statement. 1) 3 20 1 Returns: 3 We have only 1 ball, so we must choose which of the three baskets to place it in. 2) 3 20 2 Returns: 6 We can place both balls in the same basket (3 ways to do this), or one ball in each of two baskets (3 ways to do this). 3) 1 5 10 Returns: 0 We have more balls than our basket can hold. 4) 4 5 10 Returns: 146 This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
http://blog.csdn.net/northwolves/archive/2005/12/12/550613.aspx关于不定方程整数解的个数的求法
题目:整数数列 {xn} ∈[0,max] , 且 ∑xi=sum, 则这样的序列共有多少个?
方法:递归Function resultcount(ByVal n As Integer, ByVal max As Integer, ByVal sum As Integer) As Integer
If n * max < sum Then resultcount = 0: Exit Function
If n = 1 Then resultcount = 1
If sum = 1 Then resultcount = n
If n > 1 Then
Dim i As Integer, temp As Integer
temp = 0
For i = 0 To max
temp = temp + resultcount(n - 1, max, sum - i)
Next
resultcount = temp
End If
End Function
免费的学习交流网站,欢迎大家访问!
http://www.j2soft.cn/
-----------------------------------
不错,并不是很难.我在这里也不是为了讨论这个问题,只是慨叹VB的地位.
至于竞赛题,感兴趣的朋友可以看看,原题如下:Question:
Problem Statement
You have several identical balls that you wish to place in several baskets. Each basket has the same maximum capacity. You are given an int baskets, the number of baskets you have. You are given an int capacity, the maximum capacity of each basket. Finally you are given an int balls, the number of balls to sort into baskets. Return the number of ways you can divide the balls into baskets. If this cannot be done without exceeding the capacity of the baskets, return 0.
Each basket is distinct, but all balls are identical. Thus, if you have two balls to place into two baskets, you could have (0, 2), (1, 1), or (2, 0), so there would be three ways to do this.
Definition
Class:
FillBaskets
Method:
countWays
Parameters:
int, int, int
Returns:
int
Method signature:
int countWays(int baskets, int capacity, int balls)
(be sure your method is public)Constraints
-
baskets will be between 1 and 5, inclusive.
-
capacity will be between 1 and 20, inclusive.
-
balls will be between 1 and 100, inclusive.
Examples:
0)
2
20
2
Returns: 3
The example from the problem statement.
1)
3
20
1
Returns: 3
We have only 1 ball, so we must choose which of the three baskets to place it in.
2)
3
20
2
Returns: 6
We can place both balls in the same basket (3 ways to do this), or one ball in each of two baskets (3 ways to do this).
3)
1
5
10
Returns: 0
We have more balls than our basket can hold.
4)
4
5
10
Returns: 146
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.
至于算法那其实是无关语言什么事的,有不少程序员连这也理解不了,更何况对此毫无了解的普通大众了。
天下无不散之筵席,vb6坚持了这么久,算是不错了。
我要陪vb6走完最后一程,不过要是我先走了vb6还没走怎么办?
关于这个问题,我们还是任其自然吧.如果,能在VB开设一个帮助大家转型,转到vb.net的版块,如何?
运作方式:
免费区即现在状态,不用变.
收费区由提问者提出要求和相应的人民币金额.由各位想赚钱的程序员去解答.
在提问者得到最满意的答案时,向CSDN版主付费.CSDN版主作为中介,收取约5到30%的提成.各位想赚钱的程序员提交解决方案给CSDN版主,由CSDN版主选择和补充.根据补充的多少得到相应的5到30%之间的数字.其它的提成,则由CSDN版主引用的解答者中按比例分成.CSDN的公司和CSDN版主的版主,按20和80的分成计算,公司得20.提问者和回答者还有相关的CSDN,要签一份网上的保密协议.
大厦将倾,独木难支!
如果楼主真的想知道其中的原因,可以看看其他论坛的vb版的状况,如果大家都在下降,就是vb无可挽回的在走下坡路了,如果只是csdn的vb版下降,那想想办法还是能挽回的。