n=int(input()) a=[0for i inrange(4)] i,j=1,1 while(j<=n): if(i%7==0or ('7'instr(i))):#7的倍数或者含有7则跳过 a[(i-1)%4]+=1#跳过次数加1 j-=1#不计被跳过的数 i+=1#下一个人 j+=1#下一个数 for i in a: print(i)
classPoint: def__init__(self,x,y,w=0,a=0,s=0,d=0,score=0): self.x,self.y,self.w,self.a,self.s,self.d,self.score=x,y,w,a,s,d,score defnewscore(self,p):#四对角得分 if(self.x+1==p.x and self.y+1==p.y): self.score+=1 p.score+=1 elif(self.x+1==p.x and self.y-1==p.y): self.score+=1 p.score+=1 elif(self.x-1==p.x and self.y+1==p.y): self.score+=1 p.score+=1 elif(self.x-1==p.x and self.y-1==p.y): self.score+=1 p.score+=1 else: pass
defbegood(self,p):#上下左右 if(self.x+1==p.x and self.y==p.y): self.d+=1 p.a+=1 elif(self.x-1==p.x and self.y==p.y): self.a+=1 p.d+=1 elif(self.x==p.x and self.y+1==p.y): self.w+=1 p.s+=1 elif(self.x==p.x and self.y-1==p.y): self.s+=1 p.w+=1 else: pass defgood(self):#是否上下左右满足 if(self.w==1and self.a==1and self.s==1and self.d==1): returnTrue
s=int(input()) p=[] for i inrange(s): s=input().split() tempP=Point(int(s[0]),int(s[1])) for eachp in p: dx=eachp.x-tempP.x dy=eachp.y-tempP.y if(not eachp.good() and dx*dx+dy*dy==1): eachp.begood(tempP) if(eachp.score!=4and dx*dx+dy*dy==2): eachp.newscore(tempP)
p.append(tempP)
ans=[0,0,0,0,0] for i in p: if(i.good()): ans[i.score]+=1
//样例: 11 H2+O2=H2O 2H2+O2=2H2O H2+Cl2=2NaCl H2+Cl2=2HCl CH4+2O2=CO2+2H2O CaCl2+2AgNO3=Ca(NO3)2+2AgCl 3Ba(OH)2+2H3PO4=6H2O+Ba3(PO4)2 3Ba(OH)2+2H3PO4=Ba3(PO4)2+6H2O 4Zn+10HNO3=4Zn(NO3)2+NH4NO3+3H2O 4Au+8NaCN+2H2O+O2=4Na(Au(CN)2)+4NaOH Cu+As=Cs+Au //结果: N Y N Y Y Y Y Y Y Y N
defchemistry(x): each=x.split('+') #拆成每个化学式 res={}#化学元素字典 for item in each: i=0 num=""#存储每个化学式前面的数字 if(48<=ord(item[i])<=57):#如果开始是数字 num+=item[i] i+=1 while(i<len(item)-1and48<=ord(item[i])<=57): num+=item[i] i+=1 n=1if num==""elseint(num) #化学式前面没有数字,代表为1 re=single(item[i:],n) for key in re: res[key]=res.get(key,0)+re[key] return res defsingle(item,m): res={}#化学元素字典 i=0 s="" num="" while(i<len(item)): if(item[i]=="("): p=1 for j inrange(i+1,len(item)): if(item[j]=="("): p+=1 elif (item[j]==")"): p-=1 index=j if(p==0): break k=i+1#第一个左括号之后的位置 i=index#括号结束的位置 if(i<len(item)-1and48<=ord(item[i+1])<=57):#如果是数字 num+=item[i+1] i+=1 while(i<len(item)-1and48<=ord(item[i+1])<=57): num+=item[i+1] i+=1 n=1if num==""elseint(num) re=single(item[k:index],n*m) for key in re: res[key]=res.get(key,0)+re[key] elif(65<=ord(item[i])<=90):#如果是大写字母 s+=item[i] if(i<len(item)-1and97<=ord(item[i+1])<=122):#如果是小写字母 s+=item[i+1] i+=1 if(i<len(item)-1and48<=ord(item[i+1])<=57):#如果是数字 num+=item[i+1] i+=1 while(i<len(item)-1and48<=ord(item[i+1])<=57): num+=item[i+1] i+=1 n=1if num==""elseint(num) res[s]=res.get(s,0)+m*n#这个化学元素个数,初始为0 num="" s="" i+=1 return res
defmain(): n=int(input()) expressions=[] for i inrange(n): expressions.append(input()) for item in expressions: express=item.split("=")#每个表达式从等号分开 left,right=express[0],express[1] ans1=chemistry(left) ans2=chemistry(right) if(ans1==ans2): print('Y') else: print('N')
main()
11
H2+O2=H2O
2H2+O2=2H2O
H2+Cl2=2NaCl
H2+Cl2=2HCl
CH4+2O2=CO2+2H2O
CaCl2+2AgNO3=Ca(NO3)2+2AgCl
3Ba(OH)2+2H3PO4=6H2O+Ba3(PO4)2
3Ba(OH)2+2H3PO4=Ba3(PO4)2+6H2O
4Zn+10HNO3=4Zn(NO3)2+NH4NO3+3H2O
4Au+8NaCN+2H2O+O2=4Na(Au(CN)2)+4NaOH
Cu+As=Cs+Au
N
Y
N
Y
Y
Y
Y
Y
Y
Y
N