cyphen156
백준-심화 2 1037 약수 본문
1과 N을 제외한 N의 약수를 모두 줄 때 원래 수 N을 구하시오
제약사항
- InputCount is Divisor Count - 2
- 0 < InputCount <= 50
- 2 <= Input <= 1,000,000
주의 사항
없다.CPP풀이
약수_1037.cpp
/**
* 백준 약수_1037
* 1과 N을 제외한 N의 약수를 모두 줄 때 원래 수 N을 구하시오
*
* 제한사항
*****************************************
* InputCount is Divisor Count - 2 *
* 0 < InputCount <= 50 *
* 2 <= Input <= 1,000,000 *
*****************************************
*
*
*
* 주의
* 없다.
*
* 풀이시간 5분
*/
#include <iostream>
#define MAX_VALUE 1000001
#define MIN_VALUE 1
using namespace std;
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int inputCount;
int N;
cin >> inputCount;
int divisors[2];
divisors[0] = MAX_VALUE;
divisors[1] = MIN_VALUE;
for (int i = 0; i < inputCount; ++i)
{
int input;
cin >> input;
if (divisors[0] > input)
{
divisors[0] = input;
}
if (divisors[1] < input)
{
divisors[1] = input;
}
}
N = divisors[0] * divisors[1];
cout << N << '\n';
return 0;
}
모든 예제 코드의 소스파일은 제 개인 깃허브 레포지토리에 있습니다.
Workspace/알고리듬 풀이 at main · cyphen156/Workspace
Studying . Contribute to cyphen156/Workspace development by creating an account on GitHub.
github.com
'컴퓨터공학 > 알고리듬 풀이' 카테고리의 다른 글
백준-심화 2 26069 붙임성 좋은 총총이 (0) | 2025.07.10 |
---|---|
백준-심화 2 25192 인사성 밝은 곰곰이 (0) | 2025.07.10 |
백준-조합론 1010 다리 놓기 (3) | 2025.07.09 |
백준-조합론 11050 이항 계수 1 (0) | 2025.07.09 |
백준-조합론 10872 팩토리얼 (0) | 2025.07.09 |