Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- map
- 시스템프로그래밍
- vector
- priority_queue
- 라인트레이서
- stl
- 자료구조
- 아두이노
- 수광 소자
- Visual Micro
- html
- Deque
- WinAPI
- Array
- LineTracer
- 운영체제
- 아두이노 컴파일러
- c++
- set
- 컴퓨터 그래픽스
- C언어
- arduino compiler
- 아두이노 소스
- queue
- 통계학
- Stack
- Arduino
- directx
- list
- Algorithm
Archives
- Today
- Total
Kim's Programming
1945. 간단한 소인수분해 본문
1945. 간단한 소인수분해
문제출처: https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5Pl0Q6ANQDFAUq&categoryId=AV5Pl0Q6ANQDFAUq&categoryType=CODE
풀이 방법
주어진 숫자를 큰 숫자부터 나눠본다 나눠지지 않으면 그 다음 숫자를 이용하여 나눠준다
<코드>
#include<iostream> #include<cstring> using namespace std; int returnValue(int &origin, int target) { int retval{ 0 };// = origin / target; 50 5 while (origin % target ==0) { origin /= target; retval++; } return retval; } int main(int argc, char** argv) { int test_case; int T; cin >> T; for (test_case = 1; test_case <= T; ++test_case) { int input; std::cin >> input; int a, b, c, d, e; e = returnValue(input, 11); d = returnValue(input, 7); c = returnValue(input, 5); b = returnValue(input, 3); a = returnValue(input, 2); std::cout << "#" << test_case << " " << a << " " << b << " " << c << " " << d << " " << e << "\n"; } return 0;//정상종료시 반드시 0을 리턴해야합니다. }
'SW ExpertAcademy > D2' 카테고리의 다른 글
1948. 날짜 계산기 (0) | 2018.12.01 |
---|---|
1946. 간단한 압축 풀기 (0) | 2018.12.01 |
1940. 가랏! RC카! (0) | 2018.12.01 |
1928. Base64 Decoder (0) | 2018.12.01 |
1288. 새로운 불면증 치료법 (0) | 2018.12.01 |