-
백준 1094번: 막대기구현(Implementation) 2018. 8. 4. 14:10반응형
https://www.acmicpc.net/problem/1094
1. 문제
2. 알고리즘
키워드 - 구현
3. 코드
12345678910111213141516171819202122232425262728293031323334353637383940#include <iostream>#include <sstream>#include <string>#include <algorithm>#include <functional>#include <vector>#include <list>#include <queue>#include <deque>#include <map>#include <set>#include <stack>#include <math.h>#include <memory.h>#include <intrin.h>using namespace std;#define MAX_SIZE 100#define INF 0x7fffffff#define CENDL "\n"#define ll long longint main() {cin.tie(0);std::ios::sync_with_stdio(false);int n; cin >> n;int sol = 0;while (n != 0) {if (n % 2 == 1) {sol++;}n /= 2;}cout << sol << "\n";return 0;}cs 1234567891011121314151617181920212223242526272829303132#include <iostream>#include <sstream>#include <string>#include <algorithm>#include <functional>#include <vector>#include <list>#include <queue>#include <deque>#include <map>#include <set>#include <stack>#include <math.h>#include <memory.h>#include <intrin.h>using namespace std;#define MAX_SIZE 100#define INF 0x7fffffff#define CENDL "\n"#define ll long longint main() {cin.tie(0);std::ios::sync_with_stdio(false);int n; cin >> n;cout << __popcnt(n);return 0;}cs 반응형'구현(Implementation)' 카테고리의 다른 글
백준 2312번: 수 복원하기 (0) 2018.08.05 백준 1790번: 수 이어 쓰기 2 (0) 2018.08.04 백준 11008번: 복붙의 달인 (0) 2018.08.03 백준 10101번: 삼각형 외우기 (0) 2018.08.03 백준 1773번: 폭죽쇼 (0) 2018.08.03