赞
踩
答案:4097482414389
解析:代码如下
-
- def judge(num):
- string = str(num)
- if( '2' in string or '0' in string or '1' in string or '9' in string):
- return True
- return False
-
-
- if(__name__=='__main__'):
- cnt = 0
- for a in range(1,2020):
- if(judge(a)):
- cnt+=(a*a*a)
-
-
- print(cnt)
-
答案:3725573269
解析:将其看成26进制的数,代码如下
- if(__name__=='__main__'):
- num = 0
- string = 'LANQIAO'
- jw = 0
- for i in range(0,len(string)):
- num=(ord(string[i])-ord('A')+1+num*26)
- jw+=1
- print(num)
答案:17569
解析:代码如下
- import math
- def is_prime(num):
- if(num>3):
- for i in range(2,int(math.sqrt(num)+1)):
- if(num%i==0):
- return False
- return True
-
-
- if(__name__=='__main__'):
- cnt = 0
- num = 2
- while(True):
- if(is_prime(num)):
- cnt+=1
- if(cnt==2019):
- print(num)
- break
- num+=1
-
答案:6
解析:不需要代码,直接自己用最短路手动找还快一点,我随意找了三条路,有错误请指出
答案:579706994112328949
解析:题目有提示,当n足够大时会趋近黄金分割,自己测试一下找到黄金分割的阈值,代码如下
- if(__name__=='__main__'):
- f = [1,1]
- index = 1
- n = int(input())
- if( n == 1 ):
- print(1)
- elif( n == 2 ):
- print('0.50000000')
- elif( n > 30 ):
- print('0.61803399')
- else:
- for i in range(2,n+1) :
- tmp = f[1]+f[0]
- index = (index+1)%2
- f[index] = tmp
- print('%.8lf' % (f[index]/(f[1]+f[0])))
解析:我的答案有点问题,但我找不到问题在哪,有大佬请帮我指出
- def get_l(nums,n):
- l = 1
- while(True):
- res = judge(nums,l)
- if(res):
- return l
- l += 1
-
- def judge(nums,l):
- sweep = 0
- for i in range(len(nums)):
- it = nums[i]
- if(it-l<=sweep):
- if(it<=sweep):
- sweep=it+l-1
- else:
- sweep+=l
- else:
- return False
- return True
-
- if(__name__=='__main__'):
- nks = input().split()
- n = int(nks[0])
- k = int(nks[1])
- nums = []
- l=n
- for i in range(k):
- nums.append(int(input()))
- nums.sort()
- l = 0
- r = n
- ans = n
- while(l<=r):
- m = int((l+r) // 2)
- res = judge(nums,m)
- if(res):
- r = m-1
- ans = m
- else:
- l = m+1
-
- print(2*(ans-1))
答案:代码如下
- def get_next(num,l):
- while(num in l):
- num += 1
- return num
-
- if(__name__=='__main__'):
- s_l = set()
- n = int(input())
- l = input().split()
- vis = [0 for i in range(1111111)]
- for i in range(len(l)):
- if(not i==0):
- print(' ',end = '')
- num = int(l[i])
- while(vis[num]==1):
- num += 1
- vis[num]=1
- s_l.add(num)
- print(num,end = '')
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。