Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- 그리디 알고리즘
- 알고리즘
- 구현
- 자료구조
- c++
- 수학
- 유니온 파인드
- DFS
- 브루트포스
- 투 포인터
- 재귀
- 트리
- ue5
- 다익스트라
- Team Fortress 2
- 백트래킹
- 다이나믹 프로그래밍
- 시뮬레이션
- 백준
- 스택
- BFS
- 문자열
- XR Interaction Toolkit
- 그래프
- 유니티
- 우선순위 큐
- 정렬
- Unreal Engine 5
- VR
- 누적 합
Archives
- Today
- Total
1일1알
백준 10166번 관중석 C++ 본문
https://www.acmicpc.net/problem/10166
10166번: 관중석
KOI 공연장의 관중석에는 가운데에 있는 무대를 중심으로 반지름이 자연수인 동심원(중심이 같은 여러 원들) 위에 다음과 같이 좌석들이 배치되어 있다. 반지름이 1인 원 위에는 좌석이 1개, 반지
www.acmicpc.net
각도를 직접 구하면 오차가 있을 수 있어서 분수 형태로 풀었다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int d1, d2;
set<pair<int,int>> s;
int Gcd(int a, int b) {
if (a % b == 0) return b;
else return Gcd(b, a % b);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> d1 >> d2;
for (int i = d1; i <= d2; i++) {
for (int j = 1; j < i; j++) {
int gcd = Gcd(i, j);
s.insert({ i / gcd,j / gcd });
}
}
cout << s.size() + 1;
}
'알고리즘' 카테고리의 다른 글
백준18429번 근손실 C++ (0) | 2023.02.23 |
---|---|
백준 11265번 끝나지 않는 파티 C++ (0) | 2023.02.22 |
백준 2594번 놀이공원 C++ (0) | 2023.02.20 |
백준 1464번 뒤집기 3 C++ (1) | 2023.02.19 |
백준 24230번 트리 색칠하기 C++ (0) | 2023.02.18 |