由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - 问个IQ 题
相关主题
问一道C++编程题请教一个bloomberg题目
Structured To-Do list before Interview (yc)float的格式化打印
问个C++题补 ms onsite 面筋
再问个fork的题 (转载)Python 里有类似 Sprintf 的函数么?
问个Print null的问题这题有好办法吗?
问个弱问题:为啥要设立throw exception这种机制呢?A simple interview question
问个基础题,大家不要笑我贴点面试题, ms和google的
Job opportunity: Senior formulation scientist (转载)那个24 game given 4 number用= - × /的题
相关话题的讨论汇总
话题: sprintf话题: cross话题: c++话题: sum话题: scanf
进入JobHunting版参与讨论
1 (共1页)
J**B
发帖数: 204
1
有四个人要过一座桥,每次只能过两个人。P1 要1秒钟,p2 要2秒钟,p3要5秒钟,p4
要10秒钟,四个只有一个电筒,过桥的时候必需有一个人拿个电筒照明,请问最快多少
秒4个人可以全部通过。
l*****a
发帖数: 14598
2
please check PIE

p4

【在 J**B 的大作中提到】
: 有四个人要过一座桥,每次只能过两个人。P1 要1秒钟,p2 要2秒钟,p3要5秒钟,p4
: 要10秒钟,四个只有一个电筒,过桥的时候必需有一个人拿个电筒照明,请问最快多少
: 秒4个人可以全部通过。

c*********t
发帖数: 2921
3
这不就是DP吗?

【在 J**B 的大作中提到】
: 有四个人要过一座桥,每次只能过两个人。P1 要1秒钟,p2 要2秒钟,p3要5秒钟,p4
: 要10秒钟,四个只有一个电筒,过桥的时候必需有一个人拿个电筒照明,请问最快多少
: 秒4个人可以全部通过。

J**B
发帖数: 204
4
啥 我不是CS出身,给稍微明确的hint吧。。。

【在 c*********t 的大作中提到】
: 这不就是DP吗?
s******n
发帖数: 3946
5
1,2 ->
1 <-
5, 10 ->
2<-
1, 2->
w****o
发帖数: 2260
6
大牛,
你能把这个formulate成一个DP吗?
谢谢!

【在 s******n 的大作中提到】
: 1,2 ->
: 1 <-
: 5, 10 ->
: 2<-
: 1, 2->

J**B
发帖数: 204
7
能推荐点书么

1,2 -
★ Sent from iPhone App: iReader Mitbbs Lite 7.51

【在 s******n 的大作中提到】
: 1,2 ->
: 1 <-
: 5, 10 ->
: 2<-
: 1, 2->

s******n
发帖数: 3946
S******t
发帖数: 151
9
#include
#include
using namespace std;
char cross[3000][20];
int main()
{
int n,i,nc=0,sum=0,t[1000];
scanf("%d",&n);
for(i=0;i scanf("%d",&t[i]);
sort(t,t+n);
for(i=n-1;i>=3&&2*t[1] {
sprintf(cross[nc++],"%d %d\n",t[0],t[1]);
sprintf(cross[nc++],"%d\n",t[0]);
sprintf(cross[nc++],"%d %d\n",t[i-1],t[i]);
sprintf(cross[nc++],"%d\n",t[1]);
sum+=2*t[1]+t[0]+t[i];
}
for(;i>=2;i--)
{
sprintf(cross[nc++],"%d %d\n",t[0],t[i]);
sprintf(cross[nc++],"%d\n",t[0]);
sum+=t[0]+t[i];
}
if(i==1)
{
sprintf(cross[nc++],"%d %d\n",t[0],t[1]);
sum+=t[1];
}
else
{
sprintf(cross[nc++],"%d\n",t[0]);
sum+=t[0];
}
printf("%d\n",sum);
for(i=0;i printf("%s",cross[i]);
return 0;
}
This version can handle n persons.
1 (共1页)
进入JobHunting版参与讨论
相关主题
那个24 game given 4 number用= - × /的题问个Print null的问题
伪O(1) space的O(n)时间重新排列a1a2a3...b1b2b3...算法问个弱问题:为啥要设立throw exception这种机制呢?
1小时前的G家onsite面经问个基础题,大家不要笑我
问下LeetCode上的题目:count and sayJob opportunity: Senior formulation scientist (转载)
问一道C++编程题请教一个bloomberg题目
Structured To-Do list before Interview (yc)float的格式化打印
问个C++题补 ms onsite 面筋
再问个fork的题 (转载)Python 里有类似 Sprintf 的函数么?
相关话题的讨论汇总
话题: sprintf话题: cross话题: c++话题: sum话题: scanf