这次比赛好难啊……
s='WHERETHEREISAWILLTHEREISAWAY'
l=[]
for i in s:
i=ord(i)
l.append(i)
l.sort()
ss=[]
print(l)
for i in l:
i=chr(i)
ss.append(i)
print(''.join(ss))
#AAAEEEEEEHHHIIILLRRRSSTTWWWY
直接暴力跑不出来,故而猜个数(比赛当天日期),好像刚好猜对了
有问题吗?没有问题
for i in range(2,50):
print(2022040920220409%i)
a=[[1189,841]]
s=input()
s=int(s[1])
'''for i in range(1,10):
chang=max(a[i-1][0],a[i-1][1])
chang=chang//2
duan=min(a[i-1][0],a[i-1][1])
if chang
a=[[1189, 841], [841, 594], [594, 420], [420, 297], [297, 210], [210, 148], [148, 105], [105, 74], [74, 52], [52, 37]]
for i in a[s]:
print(i)
注意一下长边在上
def he(n):
n=str(n)
res=0
for i in range(len(n)):
res+=int(n[i])
return res
n=int(input())
m=int(input())
ans=0
s=[]
for i in range(1,n+1):
s.append(i)
s=sorted(s,key=lambda x:he(x))
#print(s)
print(s[m-1])
``
4.17更新
新写的,民间数据OJ测了一下AC
我要写吐了
考场上写的那个代码凉凉了
from math import *
di=[[1,0,0],[0,1,0],[0,0,1],[-1,0,0],[0,-1,0],[0,0,-1]]
a,bb,cc,d,e,f=map(int,input().split())
#a,bb,cc,d,e,f=0,5,3,1,3,2
b=(a,bb,cc)
c=(d,e,f)
def zuo(b):
d,p,q=b[0],b[1],b[2]
x,y,z=0,0,0
x+=di[d][0]*p
y+=di[d][1]*p
z+=di[d][2]*p
d=(d+2)%6
x+=di[d][0]*q
y+=di[d][1]*q
z+=di[d][2]*q
return [x,y,z]
zb,zc=zuo(b),zuo(c)
#print(zb,zc)
l=list(map(lambda x,y:x-y, zc,zb))
#print(l)
'''if l[1]==0 or l[0]==0 or l[2]==0:
print(abs(zb[0]-zc[0])+abs(zb[1]-zc[1])+abs(zb[2]-zc[2]))'''
if 1:
f=0
die=[[-1,0],[-1/2,sqrt(3)/2],[1/2,sqrt(3)/2]]
#print(l)
x=l[0]*die[0][0]+l[1]*die[1][0]+l[2]*die[2][0]
y=l[0]*die[0][1]+l[1]*die[1][1]+l[2]*die[2][1]
#print(x,y)
if x!=0:
t=atan(y/x)
else:
print(round(y/sqrt(3)*2))
f=1
if f==0:
if y/x==0:
print(round(x))
elif y/x==-sqrt(3):
print(round(x*2))
elif y/x==sqrt(3):
print(round(x*2))
elif 0>t and t>-1.0471975511965976:
print(abs(l[0]-l[2])+abs(l[1]+l[2]))
elif t>0 and t<1.0471975511965976:
print(abs(l[0]+l[1])+abs(l[1]+l[2]))
else:
print(abs(l[0]+l[1])+abs(l[2]-l[0]))
s=input()
print('EMPTY')
比赛完之后做出来了呜呜呜,感觉挺暴力的,不知道能过多少个测试点
s=input()
def xiao(l):
vis=[0]*len(l)
s=''
for i in range(1,len(l)-1):
if l[i]==l[i-1] and l[i]!=l[i+1]:
vis[i]=1
vis[i+1]=1
if l[i]==l[i+1] and l[i]!=l[i-1]:
vis[i]=1
vis[i-1]=1
for i in range(len(l)):
if vis[i]==0:
s+=l[i]
return s
s1=s
for i in range(1<<64):
s=xiao(s)
if len(s1)==len(s):
break
s1=s
if s=='':
print('EMPTY')
else:
print(s)
def jia(s):
f=[0]*(len(s))
for i in range(0,len(s)):#qian
for j in range(i+1,len(s)):
if s[i]<s[j]:
f[j]+=1
return sum(f)% 998244353
#print(jia((3,1,2)))
#biao=[9,72,600,5400,52920,564480,6531840,81648000]
from itertools import *
n=int(input())
ans=0
s=[i for i in range(1,n+1)]
for i in permutations(s):
ans+=jia(i)%998244353
print(ans)
permutation慢的要死,打表后直接找规律
from math import *
s=[i for i in range(100010)]
l=[i for i in range(100010)]
for i in range(1,len(s)):
l[i]=(l[i-1]+s[i])
#print(l)
s=int(input())
aa=factorial(s)
#print(l[s],aa)
ans=((aa*l[s-1])>>1)%998244353
print(ans)
4.17更新
继续优化一下。。。
from math import *
def qiuhe(s):
return (s)*(s-1)//2
s=int(input())
aa=1
for i in range(1,s+1):
aa=aa*i%998244353
ans=(aa*qiuhe(s)//2)%998244353
print(ans)
from math import *
n,m=map(int,input().split())
l=[]
ll=[]
for i in range(n):
l.append(list(map(int,input().split())))
l[i].append(ceil(l[i][0]/l[i][1]))
ll.append(l[i][0])
for i in range(len(l)):
a,b,c=l[i][0],l[i][1],l[i][2]
b1=b
for j in range(l[i][2]-1):
ll.append(a-b)
b+=b1
ll.sort(reverse=1)
#print(ll)
print(sum(ll[:m]))
暴力出来,不知道能过多少
n,k=map(int,input().split())
a=list(map(int,input().split()))
maxa=max(a)
cnt=0
def wu0(l):
if 0 in l:
return 0
return 1
def jian(l,k):
ll=[-1]*k
ll2=[]
for i in range(k):
ll2.append(l[i]+ll[i])
return ll2
cnt1=-1
#while sum(a)!=0:
while cnt!=cnt1:
for i in range(0,n-k+1):
lian=a[i:i+k]
#print(lian,wu0(lian))
cnt1=cnt
if wu0(lian):
s=jian(a[i:i+k],k)
a[i:i+k]=s
cnt+=1
cnt+=sum(a)
print(cnt)
直接暴力,可能有点小细节没考虑到,但是测试样例过了,时间也快到了
本人刚学py两个多月,还很菜……本题解不保证正确性,欢迎各位大佬指点