1424번: 새 앨범
첫째 줄에 노래의 개수 N이 주어진다. 이 값은 100,000보다 작거나 같은 자연수이다. 둘째 줄에는 노래의 길이 L이 주어진다. 이 값은 초 단위이다. 셋째 줄에는 한 시디의 용량 C가 초 단위로 주어
www.acmicpc.net
포기~!!
import math
import sys
input = sys.stdin.readline
n = int(input())
l = int(input())
c = int(input())
num = (int)(math.ceil(c-l)/(l+1)) + 1
if num % 13 == 0:
num -= 1
elif n < num:
if n % 13 == 0:
print(2)
else:
print(1)
sys.exit()
if n % num == 0:
print(n // num)
else:
print((n // num) +1)
이거 그래도 86까지는 가요..,
import sys
input = sys.stdin.readline
n = int(input())
l = int(input())
c = int(input())
ans, cnt = 0, 0
temp = c
check = 0
while(cnt != n):
print(cnt,temp)
if temp <= l:
temp = c
ans += 1
if temp < l:
cnt -= 1
if check % 13 == 0:
cnt -= 1
check = 0
else:
temp -= l + 1
check += 1
cnt += 1
else:
if temp >= 0:
ans += 1
print(ans)
시간 초과 나온 코드인데, 이렇게 for문 돌리면 안 되고 공식 써야하나봐요
그래도 저거 돌리면 어떻게 돌아가는지 알 수 있어서요...일단 얘도 올립니당...
질문게시판에 있는 코드 참고해서 질문게시판에 있는 예제랑 본문 예제 다 나오게 고쳤는데 틀림 나와서 속 완죤 터지네용
import math
import sys
input = sys.stdin.readline
n = int(input())
l = int(input())
c = int(input())
num = (int)(math.ceil(c-l)/(l+1)) + 1
if num % 13 == 0:
num -= 1
elif n < num:
if n % 13 == 0:
print(2)
else:
print(1)
sys.exit()
ans = n // num
if (n-num)%13 == 0:
ans += 1
if n % num == 0:
print(ans)
elif n % num != 0:
print(ans+1)
질문게시판 포함 예제 다 돌아가는데 3퍼에서 틀렸다고 나오는 코드 (위에 코드)
import math
import sys
input = sys.stdin.readline
n = int(input())
l = int(input())
c = int(input())
num = (int)(math.ceil(c-l)/(l+1)) + 1
if num % 13 == 0:
num -= 1
elif n < num:
if n % 13 == 0:
print(2)
else:
print(1)
sys.exit()
if n % num == 0:
print(n // num)
elif n % num != 0:
print((n // num) +1)
86까지는 가는데 예제 틀리게 나오는 코드 ㅠ
53
1
54
27
1
27
이 예제 두개가 약간 옹 글쿤 할 수 있는 예제였슴니다
아 저 맨위에 코드 약간 틀리긴 했어요
2.5 for-else와 while-else - 왕초보를 위한 Python: 쉽게 풀어 쓴 기초 문법과 실습 (wikidocs.net)
for else말고 while else도 있는거 첨 알았네용
'BOJ' 카테고리의 다른 글
[python] 백준 1647번 - 도시 분할 계획 (0) | 2023.08.05 |
---|---|
[python]백준 1149번 - RGB거리 (0) | 2023.08.04 |
[python]백준 1600번 - 말이 되고픈 원숭이 (0) | 2023.08.03 |
[python]백준 3020번 - 개똥벌레 (0) | 2023.08.02 |
[python]백준 1253번 - 좋다 (0) | 2023.08.01 |
댓글