코딩 및 기타
오일러1084,1085
정지홍
2023. 1. 21. 10:36
#1084 Doubles : 오일러OJ (euleroj.io)
#2이상 15이하의 중복되지 않는 양의 정수 리스트
#이 리스트에 2의 배수가 몇개가 있는지 구한다
#2의 배수는 이 리스트에의 숫자안에서만
a=list(map(int, input().split()))
cnt=0
for i in range(0,len(a)):
for j in range(i,len(a)):
if a[i]*2==a[j] or a[j]*2==a[i]:
if a[i]!=0 and a[j]!=0:
cnt+=1
#print(a[i])
#print(a[j])
#print()
print(cnt)
#1085 연속구간 : 오일러OJ (euleroj.io)
#여덟자리 양의 정수
#이 안에서 연속하여 같은 숫자가 없으면 1
#아니면 그 구간중 가장 긴 것의 길이를 출력
def rst(st):
max=0
cnt=1
for i in range(0,len(st)-1):
if st[i]==st[i+1]:
cnt+=1
#print("%s %d"%(st[i],cnt))
else:
if cnt>max:
max=cnt
cnt=1
if i==6 and cnt>max:
if st[i]==st[i+1]:
max=cnt
# print()
if max==0:
return 1
else:
return max
x=input()
y=input()
z=input()
cntX,cntY,cntZ=rst(x),rst(y),rst(z)
print(cntX)
print(cntY)
print(cntZ)