百度笔试算法ac+ac


def shoot():
inputlines = input("input:")
res = inputlines.split(" ")
n=int(res[0])
m=int(res[1])
sum = 0
i = 2
j = 2+2*n
while i<(2*n+2) and j<(2+2*n+m):
print(res[i+1],"***",res[i],"***",res[j])
if int(res[j])>=int(res[i]) and int(res[j]) <=int(res[i+1]):
sum+=1
i=2
j+=1
if j==2+2*n+m:
print(sum)
else:
i+=2
if i==2*n+2 :
j+=1
i = 2

if "__main__":
# data = "3 3 1 5 2 6 7 8 10 4 8"
shoot()

def ditui2(input_list, n):
result = 0
while(n > 4):
result = input_list[0] + input_list[1] + input_list[3]
input_list.append(result)
input_list = input_list[1:]
n -= 1
print(result % (10**9+7))

if __name__ == '__main__':
line = input()
input_list = list(map(int, line.split()))
n = input_list[-1]
input_list = input_list[:-1]
ditui2(input_list, n)

#百度##笔试题目#
全部评论
第二题这样写 a了?我这样写才0.09
点赞 回复
分享
发布于 2019-09-17 21:49
a了96的C++版 #include<algorithm> #include<iostream> typedef long long LL; using namespace std; LL a[10000]; const LL mod = 1000000007; int main() {  int n;  memset(a, 0, sizeof(a));  for (int i = 1; i <= 4; i++) {   cin >> a[i];  }  cin >> n;  for (int i = 5; i <= n; i++) {   a[i] = a[i-1]  + a[i-3] + a[i-4];  }  LL tm = a[n]%mod;  cout <<tm<< endl;  return 0; }
点赞 回复
分享
发布于 2019-09-17 21:44
百信银行
校招火热招聘中
官网直投
我第2题也是这样写的,只不过每次是input_list[-4:],为什么还是0.09
点赞 回复
分享
发布于 2019-09-17 21:47
暴力也能ac?真的假的
点赞 回复
分享
发布于 2019-09-17 21:49
请问楼主,你写的第一题思路是啥的?我以为是二分图的最大匹配。
点赞 回复
分享
发布于 2019-09-17 22:07
不可能吧
点赞 回复
分享
发布于 2019-09-17 22:59

相关推荐

1 14 评论
分享
牛客网
牛客企业服务