์ฝ์, ๋ฐฐ์์ ์์
https://www.acmicpc.net/problem/5086
while True:
l = list(map(int,input().split()))
if l[0]==0 and l[1]==0:
break
elif max(l)%min(l)==0:
if l.index(max(l))==0:
print('multiple')
else:
print('factor')
else:
print('neither')
https://www.acmicpc.net/problem/9506
while True:
n = int(input())
if n==-1:
break
else:
l=[]
for i in range(1,n):
if n%i==0:
l.append(i)
else:
pass
if n==sum(l):
print(f'{n} = 1',end='')
for x in l[1:]:
print(f' + {x}',end='')
print()
else:
print(f'{n} is NOT perfect.',end='\n')
๋ฐ๋ณต๋ฌธ์์
print(n, " = ", " + ".join(str(i) for i in l), sep="")
์ด๋ ๊ฒ ์์ฑํด๋ ๋๋ค.
https://www.acmicpc.net/problem/1978
n = int(input())
l = list(map(int,input().split()))
f=[]
# ์์์ธ์ง ํ๋ณํ๋ ํจ์
def is_prime(num):
if num < 2:
return False
for i in range(2, num):
if num % i == 0:
return False
return True
# ๊ฐ ์ซ์๊ฐ ์์์ธ์ง ํ๋ณํ์ฌ ๋ฆฌ์คํธ์ ์ถ๊ฐ
for x in l:
if is_prime(x):
f.append(x)
print(len(f))
ํ์ด์ฌ์์๋ range(2,1) ์ด๋ range(2,2) ์ด๋ ๊ฒ ๋์ด์์ด๋ ์๋ฌ๋ฅผ ์ผ์ผํค์ง ์๋๋ค. ๋์ ๋น ๋ฒ์
๋ค๋ฅธ ํ์ด:
n = int(input())
data = list(map(int, input().split()))
count = 0
for x in data:
for i in range(2, x+1):
if x % i == 0:
if x == i:
count += 1
break
print(count)
https://www.acmicpc.net/problem/2581
min_n = int(input())
max_n = int(input())
f=[]
for i in range(min_n,max_n+1):
for j in range(2,i+1):
if i%j==0:
if j==i:
f.append(i)
else:
break
if sum(f)==0:
print('-1')
else:
print(sum(f))
print(f[0])
https://www.acmicpc.net/problem/11653
n = int(input())
for i in range(2,n+1):
if n%i==0:
while n%i==0:
print(i)
n=n/i
๊ธฐํ: ์ง์ฌ๊ฐํ๊ณผ ์ฌ๊ฐํ
https://www.acmicpc.net/problem/3009
x=[]
y=[]
for i in range(3):
a,b=map(int,input().split())
x.append(a)
y.append(b)
for j in x:
if x.count(j)==1:
print(j)
for j in y:
if y.count(j)==1:
print(j)
'๐ CodingTest' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
Python ๋ฐฑ์ค ๋ฌธ์ ํ์ด(์งํฉ๊ณผ ๋งต) (1) | 2024.04.29 |
---|---|
Python ๋ฐฑ์ค ๋ฌธ์ ํ์ด(๋ธ๋ฃจํธ ํฌ์ค, ์ ๋ ฌ) (0) | 2024.04.28 |
Python ๋ฐฑ์ค ๋ฌธ์ ํ์ด(2์ฐจ์ ๋ฐฐ์ด, ์ผ๋ฐ์ํ1) (0) | 2024.04.26 |
Python ๋ฐฑ์ค ๋ฌธ์ ํ์ด(๋ฌธ์์ด,์ฌํ1) (0) | 2024.04.25 |
Python ๋ฐฑ์ค ๋ฌธ์ ํ์ด(์ ์ถ๋ ฅ๊ณผ ์ฌ์น์ฐ์ฐ, ์กฐ๊ฑด๋ฌธ, ๋ฐ๋ณต๋ฌธ, 1์ฐจ์ ๋ฐฐ์ด) (0) | 2024.04.23 |