일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
Tags
- 알고리즘
- Implicit method
- C
- Conjugate Gradient
- Overloading
- TIP
- 논문
- 학습용
- class
- ComputeShader
- 2020.03.16
- game jam
- 알고리즘연습
- graphics
- C++
- ppt
- oprerator
- UNORDERED_MAP
- Til
- Algorithm
- rendering pipeline
- 백준
- 독서
- numerical method
- 2020.02.23
- algorithm #알고리즘 #백준
- stretch force
- 참조자
- 프로그래머스
- sparse matrix
Archives
- Today
- Total
OSgood의 개발일기
[백준] 10166번 관중석 본문
https://www.acmicpc.net/problem/10166
10166번: 관중석
KOI 공연장의 관중석에는 가운데에 있는 무대를 중심으로 반지름이 자연수인 동심원(중심이 같은 여러 원들) 위에 다음과 같이 좌석들이 배치되어 있다. 반지름이 1인 원 위에는 좌석이 1개, 반지름이 2인 원 위에는 좌석이 2개, 이런 식으로 반지름이 D 인 원 위에는 좌석이 D 개가 있다. 또한, 무대에서 정확히 북쪽 방향에는 모든 원들에 좌석이 있으며, 하나의 원 위에 있는 좌석들은 동일한 간격을 두고 배치되어 있다. 이번 공연에 반지름이 D1보다 같
www.acmicpc.net
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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | ////백준 10166번 관중석 #include <iostream> #include <cstring> using namespace std; //bool table[2001][2001] = { 0, }; int gcd(int a, int b) { if (b == 0) { return a; } else { return gcd(b, a%b); } } int main() { int x; int y; int result = 0; scanf("%d %d", &x, &y); int **table = new int*[y+1]; for (int i = 0; i <= y; i++) { table[i] = new int[y+1]; memset(table[i], 0, sizeof(int)*(y + 1)); } result++; int temp_gcd; int tmp_a; int tmp_b; for (int i = x; i <= y; i++) { for (int j = 1; j < i; j++) { temp_gcd = gcd(i, j); tmp_a = i / temp_gcd; tmp_b = j / temp_gcd; if (table[tmp_a][tmp_b] == 0) { result++; table[tmp_a][tmp_b] = 1; } } } printf("%d\n", result); for (int i = 0; i <= y; i++) { delete[] table[i]; } delete[] table; return 0; } | cs |
'Algorithm > Algorithm 문제 연습' 카테고리의 다른 글
[백준] 8983번 사냥꾼 (0) | 2020.03.21 |
---|---|
[백준] 10165 버스 노선 (0) | 2020.03.14 |
[백준] 10837번 동전 게임 (0) | 2020.03.13 |
[백준] 1715번 카드 정렬하기 (0) | 2020.03.08 |
[백준] 2583번 영역 구하기 (0) | 2020.02.23 |
Comments