본문 바로가기

Algorithm_BOJ(백준)/조합론

[백준 5086 c++ O] 배수와 약수

728x90
반응형

- 풀이링크: 

https://github.com/xhaktmchl/Algorithm_study/blob/main/BOJ/%EC%A1%B0%ED%95%A9%EB%A1%A0/%5B%EB%B0%B1%EC%A4%80%205086%20c%2B%2B%20O%5D%20%EB%B0%B0%EC%88%98%EC%99%80%20%EC%95%BD%EC%88%98.cpp

 

GitHub - xhaktmchl/Algorithm_study: 알고리즘 이론 및 문제풀이

알고리즘 이론 및 문제풀이. Contribute to xhaktmchl/Algorithm_study development by creating an account on GitHub.

github.com

#include <iostream>
#include <algorithm> // fill_n, min,max, swap
//#include <map> // 중복 x 
//#include <string> // getline
//#include <cstring> // memset, strok, strstr
#include <vector>
#include <queue> // priority_queue<자료형, 구현체, 비교 연산자> (중복허용), 
//#include <set> // 트리, 중복 x , multiset
//#include <unordered_set>
//#include <cmath>
using namespace std; // lower_bound, upper_bound
/*
[백준 5086 c++ O] 배수와 약수 
문제:
접근: 
시간복잡도: O()
풀이: 
*/
int x, y;

int main()
{
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(0);

    while (1) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;

        if (y % x == 0) cout << "factor" << endl;
        else if (x % y == 0) cout << "multiple" << endl;
        else cout << "neither" << endl;
    }
    return 0;
}
반응형