#携程笔试# 半凉经
携程21届春招数据分析专业笔试
一共2道题:Python+SQL,python的是求数字d的平方差分解,SQL是检索起始站和终点站的一览表。
python的可以直接三层for循环+if判断完成,通过代码如下:
d=int(input())
count=0
for a in range(d):
if a*a<d:
for b in range(d):
if a*a+b*b<d:
for c in range(d):
if a*a+b*b+c*c==d:
count+=1
break
if count==0:
print(0)
else:
print(1)
SQL的难在于如何判断“上海-北京”和“北京-上海”是同一路线或者车次,当时没有解出来。
table名:train_stopstations ,原始表格如下图:
看了其他贴的评论,方知解答思路如此简单明了:
SELECT t1.station as deo,t2.station as arr,t1.trainnumber from train_stopstations as t1
inner join train_stopstations as t2
on t1.trainnumber=t2.trainnumber
and t1.no<t2.no
携程21届春招数据分析专业笔试
一共2道题:Python+SQL,python的是求数字d的平方差分解,SQL是检索起始站和终点站的一览表。
python的可以直接三层for循环+if判断完成,通过代码如下:
d=int(input())
count=0
for a in range(d):
if a*a<d:
for b in range(d):
if a*a+b*b<d:
for c in range(d):
if a*a+b*b+c*c==d:
count+=1
break
if count==0:
print(0)
else:
print(1)
SQL的难在于如何判断“上海-北京”和“北京-上海”是同一路线或者车次,当时没有解出来。
table名:train_stopstations ,原始表格如下图:
看了其他贴的评论,方知解答思路如此简单明了:
SELECT t1.station as deo,t2.station as arr,t1.trainnumber from train_stopstations as t1
inner join train_stopstations as t2
on t1.trainnumber=t2.trainnumber
and t1.no<t2.no
全部评论
哦是平方和分解
相关推荐
06-09 11:12
重庆移通学院 运营 不要停下啊:大二打开牛客,你有机会开卷了,卷起来
,去找课程学习,在牛客上看看大家面试笔试都需要会什么,岗位有什么需求就去学什么,努力的人就一定会有收获,这句话从来都经得起考验,像我现在大三了啥也不会,被迫强行考研,炼狱难度开局,啥也不会
,找工作没希望了,考研有丝丝机会
点赞 评论 收藏
分享