문제 링크입니다: https://www.acmicpc.net/problem/4504
4504번: 배수 찾기
문제 정수 n(0 < n < 1000)과 수의 목록이 주어졌을 때, 목록에 들어있는 수가 n의 배수인지 아닌지를 구하는 프로그램을 작성하시오. 입력 첫째 줄에 n이 주어진다. 다음 줄부터 한 줄에 한 개씩 목록에 들어있는 수가 주어진다. 이 수는 0보다 크고, 10,000보다 작다. 목록은 0으로 끝난다. 출력 목록에 있는 수가 n의 배수인지 아닌지를 구한 뒤 예제 출력처럼 출력한다. 예제 입력 1 복사 3 1 7 99 321 777 0 예제 출력 1 복
www.acmicpc.net
간단한 문제였습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
int N; | |
cin >> N; | |
while (1) | |
{ | |
int temp; | |
cin >> temp; | |
if (temp == 0) | |
{ | |
break; | |
} | |
if (temp < N || temp % N) | |
{ | |
cout << temp << " is NOT a multiple of " << N << ".\n"; | |
continue; | |
} | |
cout << temp << " is a multiple of " << N << ".\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 1024번 수열의 합 (4) | 2019.11.11 |
---|---|
백준 1834번 나머지와 몫이 같은 수 (0) | 2019.11.11 |
백준 1964번 오각형, 오각형, 오각형... (0) | 2019.11.10 |
백준 1712번 손익분기점 (3) | 2019.11.10 |
백준 12018번 Yonsei TOTO (0) | 2019.11.09 |