洛谷
quanshu12
x小菜鸟一个
展开
-
洛谷 A+B Problem (python)
s=input().split()a=int(s[0])b=int(s[1])print(a+b)原创 2020-08-25 14:19:42 · 563 阅读 · 0 评论 -
洛谷 P1739 表达式括号匹配 这题还要优化
import syscharacter=input()chLen=len(character)count=0for i in range(chLen):ch = character[i]if ch==’(’:count=count+1elif ch==’)’:count=count-1elif ch==’@’:breakif count==0:print(‘YES’)else :print(‘NO’)原创 2020-08-25 14:14:00 · 192 阅读 · 0 评论 -
洛谷 P1426 小鱼会有危险吗(python)
s,x=map(int, input().split())v=7r=0a=s+xb=s-xwhile v!=0: if r>=b and r<=a: v*=0.98 r+=v if r>s原创 2020-08-23 11:26:38 · 297 阅读 · 0 评论 -
洛谷P1422 小玉家的电费(python)
total = int(input())if total <= 150:amount = total0.4463elif 150 < total <= 400:amount = 1500.4463+(total-150)0.4663elif total > 400:amount = 1500.4463+250*0.4663+(total-400)*0.5663print(’%.1f’ %amount)原创 2020-08-23 11:23:53 · 344 阅读 · 0 评论 -
洛谷P1706 全排列问题
import itertoolsn=int(input())array=[n for n in range(1,n+1)]row = list(itertools.permutations(array))for x in row:for y in x:print(’ ‘+str(y),end=’’)print()原创 2020-08-22 20:24:02 · 127 阅读 · 0 评论 -
洛谷 P1424 小鱼的航程(改进版)
n,k=map(int,input().split())s=0for i in range(0,k):if n!=6 and n!=7:s+=250if n==7:n=1else:n+=1print(s)原创 2020-08-22 20:14:35 · 352 阅读 · 0 评论 -
洛谷 P2705 小球
r,b,c,d,e=map(int,input().split())if c+d>e+e:sum=rc+bdelif r>b:sum=b2e+(r-b)celse:sum=r2*e+(b-r)*dprint(sum)原创 2020-08-22 20:12:48 · 155 阅读 · 0 评论 -
洛谷 P5706 【深基2.例8】再分肥宅水
t,n=input().split() #毫升肥宅快乐水a=float(t) #用于将整数和字符串转换成浮点数。b=int(n)s=a/bk=2*bprint(’%.3f\n%d’ %(s, k)) #严格精确到小数点后 3 位原创 2020-08-22 20:09:26 · 679 阅读 · 0 评论 -
P5716 【深基3.例9】月份天数
year,month = map(int,input().split()) # 输入整型数if month >= 1 and month <= 12: # 月份在1~12 if month in (1, 3, 5, 7, 8, 10, 12): # 大月 day = 31elif month in (4, 6, 9, 11): # 小月 day = 30else:#以下两种情况之一都可以判断是闰年if原创 2020-08-22 20:04:24 · 301 阅读 · 0 评论 -
洛谷 P2669 金币
k=int(input())//输入有多少天count=0now=1 #意思是现在每天要给多少金币a=0 #意思是持续给now个金币给了几天for i in range(1,k+1):count+=now #发金币了a+=1 #今天的金币给了,所以天数+1if a==now: #如果发够天数了a=0 #重置now+=1 #下会发的金币加一print(count)...原创 2020-08-22 19:55:08 · 386 阅读 · 0 评论 -
洛谷 P1534 不高兴的津津(升级版)
n=int(input()) #n是津津学习的天数j=0 #当天的不高兴值h=0 #累加不高兴值for i in range(1,n+1): #循环a,b=map(int,input().split()) #输入当天上学时间和课外补习的时间j=j+a+b-8 #记录当天的不高兴值h+=j #累加不高兴值print(h)...原创 2020-08-22 19:50:42 · 478 阅读 · 0 评论