#携程笔试# 半凉经
携程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
全部评论
哦是平方和分解
相关推荐
点赞 评论 收藏
分享
点赞 评论 收藏
分享