코딩 및 기타
오일러1108,1109,1111
정지홍
2023. 1. 26. 00:27
#1108 초등학교 5학년 : 오일러OJ (euleroj.io)
a,b=map(int,input().split())
if a<b:
for i in range(a,1000001):
if i%a==0 and i%b==0:
print(i,end=' ')
break
for i in range(a,0,-1):
if a%i==0 and b%i==0:
print(i)
break
else:
for i in range(b,1000001):
if i%a==0 and i%b==0:
print(i,end=' ')
break
for i in range(b,0,-1):
if a%i==0 and b%i==0:
print(i)
break
x=input()
xLen=len(x)
xSum=0
intArr=[]
#배수가 적용되는지 검사
zeroCnt=0
for i in range(0,xLen):
xSum+=int(x[i])
intArr.append(int(x[i]))
if x[i]=='0':
zeroCnt+=1
if zeroCnt==0:
print(-1)
if xSum%3==0 and zeroCnt!=0:
intArr=sorted(intArr,reverse=True)
for i in range(0,xLen):
print(intArr[i],end='')
elif zeroCnt!=0:
print(-1)
#1111 조약돌 : 오일러OJ (euleroj.io) --------------------------오답 아직 해결 x
def five(x,y):
c=5
r=0
t=x
while(t>0):
t-=5
r+=1
#print(r)#세로
if x>=5:
c=5
else:
c=x
#print(c)#가로
rst=r+c
if y==1:
print("%d %d"%(c,r))
return rst
def four(x,y):
c=4
r=0
t=x
while(t>0):
t-=4
r+=1
if x>=4:
c=4
else:
c=x
rst=r+c
if y==1:
print("%d %d"%(c,r))
return rst
def three(x,y):
c=3
r=0
t=x
while(t>0):
t-=3
r+=1
if x>=3:
c=3
else:
c=x
rst=r+c
if y==1:
print("%d %d"%(c,r))
return rst
def two(x,y):
c=2
r=0
t=x
while(t>0):
t-=2
r+=1
if x>=2:
c=2
else:
c=x
rst=r+c
if y==1:
print("%d %d"%(c,r))
return rst
def one(x,y):
c=1
r=0
t=x
while(t>0):
t-=1
r+=1
if x>=1:
c=1
else:
c=x
rst=r+c
if y==1:
print("%d %d"%(c,r))
return rst
def answer(x):
a=one(x,0)
b=two(x,0)
c=three(x,0)
d=four(x,0)
e=five(x,0)
arr=[]
arr.append(a)
arr.append(b)
arr.append(c)
arr.append(d)
arr.append(e)
min=a
saveIndex=0
#print(arr)
for i in range(0,5):
if arr[i]<min:
min=arr[i]
saveIndex=i
return saveIndex+1
x=int(input())
y=answer(x)
if y==1:
one(x,1)
elif y==2:
two(x,1)
elif y==3:
three(x,1)
elif y==4:
four(x,1)
elif y==5:
five(x,1)
-------------------
def five(x,y):
c=5
r=0
t=x
while(t>0):
t-=5
r+=1
#print(r)#세로
if x>=5:
c=5
else:
c=x
#print(c)#가로
rst=r+c
if y==1:
print("%d %d"%(r,c))
elif y==2:
return r
else:
return rst
def four(x,y):
c=4
r=0
t=x
while(t>0):
t-=4
r+=1
if x>=4:
c=4
else:
c=x
rst=r+c
if y==1:
print("%d %d"%(r,c))
elif y==2:
return r
else:
return rst
def three(x,y):
c=3
r=0
t=x
while(t>0):
t-=3
r+=1
if x>=3:
c=3
elif y==2:
return r
else:
c=x
rst=r+c
if y==1:
print("%d %d"%(r,c))
else:
return rst
def two(x,y):
c=2
r=0
t=x
while(t>0):
t-=2
r+=1
if x>=2:
c=2
else:
c=x
rst=r+c
if y==1:
print("%d %d"%(r,c))
elif y==2:
return r
else:
return rst
def one(x,y):
c=1
r=0
t=x
while(t>0):
t-=1
r+=1
if x>=1:
c=1
else:
c=x
rst=r+c
if y==1:
print("%d %d"%(r,c))
elif y==2:
return r
else:
return rst
def answer(x):
sameArr=[]
a=one(x,0)
b=two(x,0)
c=three(x,0)
d=four(x,0)
e=five(x,0)
arr=[]
arr.append(a)
arr.append(b)
arr.append(c)
arr.append(d)
arr.append(e)
min=a
saveIndex=0
#print(arr)
for i in range(0,5):
if arr[i]<min:
min=arr[i]
#print(i)
saveIndex=i
sameArr=[]
sameArr.append(i+1)
elif arr[i]==min:
sameArr.append(i+1)
#print(sameArr)
line128maxCnt=10000
for i in sameArr:
xx=0
if i==1:
xx=one(x,2)
elif i==2:
xx=two(x,2)
elif i==3:
xx=three(x,2)
elif i==4:
xx=four(x,2)
elif i==5:
xx-five(x,2)
if xx<line128maxCnt:
line128maxCnt=i
return line128maxCnt
x=int(input())
y=answer(x)
if y==1:
one(x,1)
elif y==2:
two(x,1)
elif y==3:
three(x,1)
elif y==4:
four(x,1)
elif y==5:
five(x,1)