2017.8.12在线笔试编程真题总结
来源:互联网 发布:好的南方二本院校知乎 编辑:程序博客网 时间:2024/06/06 05:23
昨天参加了一个笔试,说实在做的很烂,自己主要刚遇上烦心事,心思也根本不在题目上,草草写了就交卷了,今天重新打开习题做一次,有几道题目思路可能不是很对或者是没有什么思路,结果没有AC,如果有通过的朋友还望可以指点一下,在这里简单贴一下8道题目的代码,我全都是使用python写的,有一个缺点就是会出现运行超时的问题,其中有两道题目都是运行超市只能AC50%,但是其中一道题目修改了策略之后就通过了,但是另一道还没有好的思路,好了不多说这些了,下面看代码:
#!usr/bin/env python#encoding:utf-8'''__Author__:沂水寒城功能:8.12网易编程题目''''''彩砖问题'''one=raw_input()one_list=list(one)length=len(set(one_list))if length>=3: print 0else: print length'''等差数列'''n=int(raw_input())str_list=raw_input().split()num_list=[int(one) for one in str_list]num_list.sort()cha=num_list[0]-num_list[1]flag=Truefor i in range(len(num_list)-1): if num_list[i]-num_list[i+1]==cha: pass else: flag=False breakif flag: print "Possible"else: print "Impossible"'''交错01串'''one_str=raw_input()length=len(one_str)i=1count=1tmp_list=[]flag=one_str[0]while i<length: if one_str[i]!=flag: count+=1 flag=one_str[i] i+=1 else: tmp_list.append(count) count=1 flag=one_str[i] i+=1if tmp_list: print max(count,max(tmp_list))else: print count'''操作序列'''n=int(raw_input())str_list=raw_input().split()if n%2==0: j=1 i=0else: j=0 i=1first_list=str_list[j:n:2]first_list.reverse()second_list=str_list[i:n:2]first_list.extend(second_list)print ' '.join(first_list)'''独立的小易'''str_list=raw_input().split()num_list=[int(one) for one in str_list]money=num_list[2]fruit=num_list[1]one_price=num_list[-1]day_money=num_list[0]if money-fruit*day_money>=0: money-=fruit*day_money count=fruit count+=money/(day_money+one_price)else: count=money/day_moneyprint count'''小易喜欢的数列,运行超市了,通过50%'''str_list=raw_input().split()n=int(str_list[0])k=int(str_list[1])matrix=[]for i in range(k+5): matrix.append([0]*(n+5))matrix[1][0]=1for i in range(1,n+1): total=0 for j in range(1,k+1): total+=matrix[j][i-1] total%=1000000007 for j in range(1,k+1): tmp=0 for m in range(2*j,k+1,j): tmp+=matrix[m][i-1] tmp%=1000000007 matrix[j][i]=(total-tmp+1000000007)%1000000007count=0for i in range(k+1): count+=matrix[i][n] count%=1000000007print count'''疯狂队列,时间有限只AC了20%'''n=int(raw_input())str_list=raw_input().split()num_list=[int(one) for one in str_list]num_list.sort()tmp_list=[]tmp_list.append(num_list.pop())tmp_list.append(num_list.pop(0))tmp_list.insert(0,num_list.pop(0))tmp=abs(tmp_list[0]-tmp_list[1])+abs(tmp_list[1]-tmp_list[2])while len(num_list)>=2: first=num_list.pop(0) last=num_list.pop(-1) tmp1=abs(first-tmp_list[0])+abs(last-tmp_list[-1]) tmp2=abs(last-tmp_list[0])+abs(first-tmp_list[-1]) if tmp1>tmp2: tmp_list.insert(0,first) tmp_list.append(last) tmp+=tmp1 else: tmp_list.insert(0,last) tmp_list.append(first) tmp+=tmp2if num_list: node=num_list.pop() if node-tmp_list[0]>node-tmp_list[-1]: tmp_list.insert(0,node) tmp+=node-tmp_list[0] else: tmp_list.append(node) tmp+=node-tmp_list[-1]print tmp'''堆棋子,没有好的思路只能AC10%'''n=int(raw_input())x_str=raw_input().split()x_list=[int(x) for x in x_str]y_str=raw_input().split()y_list=[int(y) for y in y_str]res_list=[]for i in range(1,n+1): tmp=10000000000000000 for j in range(n): for k in range(n): total=0 tmp_list=[] for h in range(n): x1=x_list[h] y1=y_list[h] dis=abs(x1-x_list[j])+abs(y1-y_list[k]) total+=dis tmp_list.append(dis) if tmp_list: total-=tmp_list.pop() tmp=min(tmp,total) res_list.append(tmp) result=[str(one) for one in res_list] print ' '.join(result)
如果需要或者感兴趣的话可以在在线测试平台简单的测试一下,希望对于我尚未解决的几道题目,高手不吝赐教,谢谢!
阅读全文
0 0
- 2017.8.12在线笔试编程真题总结
- 360在线笔试编程题
- 笔试编程题总结
- 百度php/jsp职位在线笔试真题专家解答
- 360在线笔试编程题2018
- CVTE 2018 Android在线笔试编程题
- 科大讯飞 2017在线笔试编程题
- 2017年小红书在线笔试编程第一题
- 2017年小红书在线笔试编程第二题
- 在线笔试编程技巧
- 20170910笔试在线编程
- 京东2017实习生招聘——在线笔试编程题总结
- 笔试题9. 360在线笔试题-编程题
- 笔试真题解析 ALBB-2015 校招研发在线笔试题
- 笔试真题解析 TT-2016 研发工程师在线模拟笔试题
- 笔试真题解析 2016 SYDZ 校招在线笔试题
- 中兴笔试编程题总结
- 百度2017春招笔试真题编程题集合
- CSU1978: LXX的图论题
- 智能小车七《上位机android》
- Redis集群搭建
- ubuntu搭建svn服务器
- 抽象类的定义及运用
- 2017.8.12在线笔试编程真题总结
- c++字符串string操作全解
- 模拟模拟交易系统(三)——UI设计
- HihoCoder
- 线段树总结(点修改+区间修改)
- React实战-React中this的用法
- 强大的在线编辑器 Tower 开源Simditor
- 程序员必备单词3
- 朱刘算法(Directed Minimum Spanning Tree/Directed MST/Minimum Arborescence/Optimum Branchings)