由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - 一道C++面试编程题
相关主题
算24的程序问一道狗家Boggle变形难题 (转载)
在C++里处理string用什么比较好?好了。终于把3-way qsort完成标准优化了:)
一个小程序差点搞死了g++,怎么回事?non-aggregate type问题
请教c++的string vector问题,谢谢! (转载)如何 measure similarity
请教一个c++ map问题complexity of set operation?
有人能解释一下这段C++代码吗can somebody help me with average running time of insertion sort?
帮帮看看这段tree insertion问个数据库的问题
[合集] 如何得到一个指向STL元素的指针?stl 源代码疑问
相关话题的讨论汇总
话题: string话题: number话题: additions话题: digits话题: plus
进入Programming版参与讨论
1 (共1页)
s***d
发帖数: 2
1
【 以下文字转载自 JobHunting 讨论区 】
发信人: saiad (happy), 信区: JobHunting
标 题: 一道C++面试编程题
发信站: BBS 未名空间站 (Mon Jan 8 21:06:55 2007), 转信
We have a string of digits, find the minimum number of additions required
for the string to equal some target number. Each addition is the equivalent
of inserting a plus sign somewhere into the string of digits. After all plus
signs are inserted, evaluate the sum as usual. For example, consider the
string "12" . With zero additions, we can achieve the number 12. If we
inse
m***t
发帖数: 254
2
this looks a lot like a top coder question, but anyway, the way to add is
only 2^10, you can use dynamic
programming or just exhaust the space with bruteforce.

equivalent
plus
So

【在 s***d 的大作中提到】
: 【 以下文字转载自 JobHunting 讨论区 】
: 发信人: saiad (happy), 信区: JobHunting
: 标 题: 一道C++面试编程题
: 发信站: BBS 未名空间站 (Mon Jan 8 21:06:55 2007), 转信
: We have a string of digits, find the minimum number of additions required
: for the string to equal some target number. Each addition is the equivalent
: of inserting a plus sign somewhere into the string of digits. After all plus
: signs are inserted, evaluate the sum as usual. For example, consider the
: string "12" . With zero additions, we can achieve the number 12. If we
: inse

f********r
发帖数: 50
3
it is a topcoder problem
i saw that before
brute force will do it

【在 m***t 的大作中提到】
: this looks a lot like a top coder question, but anyway, the way to add is
: only 2^10, you can use dynamic
: programming or just exhaust the space with bruteforce.
:
: equivalent
: plus
: So

m***t
发帖数: 254
4
i thought about it a bit, and having doubt on my original answer. Since we
are going for a specific target
number, not a minimal, i doubt dynamic programming can be applied here. I
donot have a good dynamic
programming solution to this problem.
also the 2^10 should be 2^9.

【在 f********r 的大作中提到】
: it is a topcoder problem
: i saw that before
: brute force will do it

f********r
发帖数: 50
5
here is the link to the problem
http://www.topcoder.com/tc?module=ProblemDetail&rd=5072&pm=2829
you may need to register an id to view it

【在 f********r 的大作中提到】
: it is a topcoder problem
: i saw that before
: brute force will do it

s*******d
发帖数: 59
6
strings find_solution(string, N)
{
for (i=0; i < string.length; i++)
{
head = string.substring(0, i);
rest = find_solution(string+i,N - int.parse(part1));
if (rest != null)
{
return head + rest;
}
}
return null;
}
s*******d
发帖数: 59
7
不过,不是最优解
1 (共1页)
进入Programming版参与讨论
相关主题
stl 源代码疑问请教一个c++ map问题
one question about initializaiton list有人能解释一下这段C++代码吗
请教Office Automation Add-in的高手帮帮看看这段tree insertion
请构造个数据结构,满足:[合集] 如何得到一个指向STL元素的指针?
算24的程序问一道狗家Boggle变形难题 (转载)
在C++里处理string用什么比较好?好了。终于把3-way qsort完成标准优化了:)
一个小程序差点搞死了g++,怎么回事?non-aggregate type问题
请教c++的string vector问题,谢谢! (转载)如何 measure similarity
相关话题的讨论汇总
话题: string话题: number话题: additions话题: digits话题: plus