求职某网站笔试被刷,求指导,求正确答案!

2013-04-12 16:10:55 +08:00
 justfly
我是今年的应届毕业生,求职某个工程师文化挺浓的公司,给了两个笔试题如下:

1.假设你的键盘只有以下键:
A
Ctrl + A
Ctrl + C
Ctrl + V
这里Ctrl+A,Ctrl+C,Ctrl+V分别代表"全选",“复制”,“粘贴”。

如果你只能按键盘N次,请写一个程序可以产生最多数量的A。也就是说输入是N(你按键盘的次数), 输出是M(产生的A的个数)。

加分项:
打印出中间你按下的那些键。


2.假设给你一个月的日志,格式如下:

[I 130403 17:26:40] 1 200 GET /question/123 (8.8.9.9) 200.39ms
[I 130403 17:26:90] 1 200 GET /topic/456 (8.8.9.9) 300.85ms
[I 130403 17:26:90] 1 200 POST /answer/789 (8.8.9.9) 300.85ms
...

方括号中依次是:级别,日期,时间,后面依次是用户id,返回码,访问方式,访问路径,用户ip,响应时间

日志文件名格式为:年-月-日-小时.log,如:2013-01-01-18.log,共30*24个文件。

写个程序,算出一个用户列表和一个路径列表符合以下要求:
1.这些用户每天都会访问(GET)/topic/***这个路径两次以上(*代表数字)
2.这些用户每天访问(GET)的/topic/***路径中,至少会包含两个不同的路径(后面的数字不一样)
3.统计出所有以上用户所访问的路径中每天都出现两次以上的路径列表

下面我给出了实现,然后**无情被拒绝**了,求指点我做的不好的地方在哪里

第一题:
<%@ var name:'56bec176509c5bb3ff16' %>

${name}

<script src="https://gist.github.com/imjustfly/56bec176509c5bb3ff16.js"></script>
第二题:
第一种实现:
<script src="https://gist.github.com/imjustfly/488998c7410e31a56072.js"></script>
第二种实现:
<script src="https://gist.github.com/imjustfly/348d352d6127cd2cbcc1.js"></script>
4326 次点击
所在节点    Python
11 条回复
justfly
2013-04-12 16:17:40 +08:00
justfly
2013-04-12 16:19:25 +08:00
justfly
2013-04-12 16:21:00 +08:00
justfly
2013-04-12 16:22:38 +08:00
justfly
2013-04-12 16:29:55 +08:00
我实在是不会用v2ex的gist了 gist地址在此 对题目有兴趣自己看吧:
第一题答案:https://gist.github.com/imjustfly/56bec176509c5bb3ff16
第二题第一种方法:https://gist.github.com/imjustfly/488998c7410e31a56072
第二题第二种方法:https://gist.github.com/imjustfly/348d352d6127cd2cbcc1
justfly
2013-04-12 16:35:45 +08:00
polythene
2013-04-12 17:44:22 +08:00
第一题是个典型的动态规划问题,可以网上搜下,很普遍的。
同求:怎样贴gist???
Xrong
2013-04-12 17:46:29 +08:00
第一题:不知道理解有木有错,楼主方便把运算结果贴下么?木有Python环境
function getit($n)
{
$biggest = $n;
$multiple = floor($n / 3);
$left = $n % 3;
if ($multiple == 0)
{
return $biggest;
}
else
{
for ($i=0; $i<$multiple; $i++)
{
$temp = ($left + 3 * $i) * pow(2, ($n - $left - 3 * $i) / 3);
$biggest = $temp > $biggest ? $temp: $biggest;
}
return $biggest;
}
}

for ($i=1; $i<20; $i++)
{
echo "Input is $i: Output is: ", getit($i);
echo "<br>";
}
我的运算结果:
Input is 1: Output is: 1
Input is 2: Output is: 2
Input is 3: Output is: 3
Input is 4: Output is: 4
Input is 5: Output is: 5
Input is 6: Output is: 6
Input is 7: Output is: 8
Input is 8: Output is: 10
Input is 9: Output is: 12
Input is 10: Output is: 16
Input is 11: Output is: 20
Input is 12: Output is: 24
Input is 13: Output is: 32
Input is 14: Output is: 40
Input is 15: Output is: 48
Input is 16: Output is: 64
Input is 17: Output is: 80
Input is 18: Output is: 96
Input is 19: Output is: 128
Input is 20: Output is: 160
Input is 21: Output is: 192
Input is 22: Output is: 256
Input is 23: Output is: 320
Input is 24: Output is: 384
Input is 25: Output is: 512
Input is 26: Output is: 640
Input is 27: Output is: 768
Input is 28: Output is: 1024
Input is 29: Output is: 1280
Xrong
2013-04-12 18:01:59 +08:00
做错了...
lin
2013-04-12 20:07:41 +08:00
把 https 改成 http 试试
xidianlz
2013-05-16 13:31:07 +08:00
我想知道第二题的
1.这些用户每天都会访问(GET)/topic/***这个路径两次以上(*代表数字)
2.这些用户每天访问(GET)的/topic/***路径中,至少会包含两个不同的路径(后面的数字不一样)
这两个条件有啥不一样?第二个条件不是包含第一个么?

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/65703

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX