회원가입
로그인
Toggle navigation
문제
문제
전체 문제
문제 출처
단계별로 풀어보기
알고리즘 분류
추가된 문제
문제 순위
문제
푼 사람이 한 명인 문제
아무도 못 푼 문제
최근 제출된 문제
최근 풀린 문제
랜덤
출처
ICPC
Olympiad
한국정보올림피아드
한국정보올림피아드시․도지역본선
전국 대학생 프로그래밍 대회 동아리 연합
대학교 대회
카카오 코드 페스티벌
Coder's High
ICPC
Regionals
World Finals
Korea Regional
Africa and the Middle East Regionals
Europe Regionals
Latin America Regionals
North America Regionals
South Pacific Regionals
문제집
대회
채점 현황
게시판
그룹
더 보기
재채점 기록
블로그
도움말
전체
공지
자유
질문
오타/오역/요청
게시판 공지
홍보
업데이트
solved.ac
글쓰기
질문 도움말
자주묻는 질문
2670 두 코드의 차이점이 무엇일까요?
2670번 - 연속부분최대곱
population
3년 전
0
while 안에 있는 것만 좀 바꾸었는데
틀렸다고 뜨네요
겉으로 보기에는 서로 같은 것처럼 보이는데 뭐가 문제일까요?
//틀렸습니다가 뜨는 코드----------- #include <iostream> int main() { int num = 0; std::cin >> num; double* num_list = new double[num]; for (int i = 0; i < num; i++) { std::cin >> num_list[i]; } double max = num_list[0]; double current = num_list[0]; int start_idx = 0; int end_idx = 0; while (end_idx < num) { if (start_idx == end_idx) current = num_list[end_idx]; else current *= num_list[end_idx]; if (current > max) max = current; if (current < 1) start_idx = end_idx; end_idx++; } std::cout << std::fixed; std::cout.precision(3); std::cout << max << std::endl; delete[] num_list; return 0; } //맞았습니다가 뜨는 코드----------- #include <iostream> int main() { int num = 0; std::cin >> num; double* num_list = new double[num]; for (int i = 0; i < num; i++) { std::cin >> num_list[i]; } double max = num_list[0]; double current = num_list[0]; int start_idx = 0; int end_idx = 0; while (end_idx < num) { if (start_idx == end_idx) current = num_list[end_idx]; else current *= num_list[end_idx]; if (current > max) max = current; if (current < 1) { start_idx = end_idx + 1; end_idx = start_idx; } else { end_idx++; } } std::cout << std::fixed; std::cout.precision(3); std::cout << max << std::endl; delete[] num_list; return 0; }
댓글을 작성하려면
로그인
해야 합니다.
population 3년 전
while 안에 있는 것만 좀 바꾸었는데
틀렸다고 뜨네요
겉으로 보기에는 서로 같은 것처럼 보이는데 뭐가 문제일까요?