회원가입
로그인
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
글쓰기
질문 도움말
자주묻는 질문
반례를 찾아주세요
2581번 - 소수
ap4r
2년 전
0
어디서 반례가 나오는지 못찾겠습니다
#include <stdio.h> int checkPrime(int iNo);//소수가 아니라면 0을, 소수라면 iNo를 return한다 int main( void ){ int iM, iN;//입력 M, N int totalPrime = 0, minPrime = 10000; int i, iPlasM;//for에 쓰일 i와 i와 함께 맞춰 바뀌는 iPlasM int currentPrime;//checkPrime에서 받은 값 scanf("%d %d", &iM, &iN); for( i = 0; i <= iN-iM; ++i ){ iPlasM = i + iM; currentPrime = checkPrime( iPlasM ); if( 0 == currentPrime ){ continue; } else { if(minPrime > currentPrime){ minPrime = currentPrime; } totalPrime = totalPrime + currentPrime; } } if( totalPrime != 0 ){ printf("%d\n%d", totalPrime, minPrime); } else { printf("-1"); } return 0; } int checkPrime( int iNo ){ int j, jPlas2; if( iNo == 1 ){ return 0; } else if( iNo == 2 ){ return 2; } else { for( j = 0; j < iNo / 2 + 1; j++ ){ jPlas2 = j + 2; if( iNo % jPlas2 == 0 ){ return 0; } } return iNo; } }
lunarlity
2년 전
2
입력 2 3
출력 2 2 (ans:5 2)
입력 3 3
출력 -1 (ans:3 3)
댓글을 작성하려면
로그인
해야 합니다.
ap4r 2년 전
어디서 반례가 나오는지 못찾겠습니다