목록분류 전체보기 (236)
정화 코딩

https://www.acmicpc.net/problem/13172 이 문제의 핵심을 정리하면 아래와 같다. 기약분수 a/b를 다음과 같이 하나의 정수로 표현할 수 있다. 이 때 X는 1,000,000,007과 같은 큰 소수이다.b^(-1)은 b의 모듈러 곱셈에 대한 역원인데, 다음과 같이 계산할 수 있다. 이 정도만 알면 문제를 풀 수 있다. 이제 구체적으로 어떻게 구현할지 생각해보자.한 줄에 분모와 분자 순서대로 한 쌍의 분수가 들어온다. 각 분수에 대해 a * b^(-1) mod X 를 구하면 된다. 그리고 모든 값들을 마치 확률을 더하듯 그냥 더해주면 된다. 내가 헷갈렸던 점은 기약분수 a/b에 대해서 저렇게 계산해야 된다고 하길래 들어온 분모와 분자에 대해서 우선 기약분수 형태로 만들어줘야..

https://www.erdcloud.com/d/DRthh5HxWMzPdEMYu

https://www.acmicpc.net/problem/12851 #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, k; cin >> n >> k; int maxs = 100001; vector vst = vector(maxs, false); int timea = 0; int cnt = 0; queue> q; q.emplace(n, 0); vst[n] = true; while (!q.empty()) { int cur = q.front().first; int t..

https://start.spring.io/위는 Spring 프로젝트 초기 세팅을 쉽게 해주는 도구이다. - Project: 프로젝트의 빌드 및 의존성을 관리하는 방식을 선택하는 항목이다. 나는 Gradle을 선택했다. - Language: 프로젝트에서 사용할 프로그래밍 언어를 선택하는 부분이다. 나는 Java를 선택했다.- Spring Boot: Spring Boot의 버전을 선택하는 항목이다. 나는 가장 안정적인 버전인 3.4.4을 선택했다.- Project Metadata: 프로젝트의 정보를 입력하는 항목이다. - Group: 프로젝트의 그룹 ID. 일반적으로 조직의 도메인 네임을 반대로 작성함. ex) com.chapssal-tteok - Artifact: 빌드된 프로젝트의 최종 결과물..

https://www.acmicpc.net/problem/23758 #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n; cin >> n; priority_queue pq; for (int i = 0; i > x; pq.push(x); } int tmp = n / 2; while (tmp--) pq.pop(); int cnt = 0; while (1) { int cur = pq.top(); pq.pop(); int nxt = cur / 2; ..

https://www.acmicpc.net/problem/11501 #include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector a(n); for (int i = 0; i > a[i]; vector b(n); for (int i = 0; i = 0; i--) { if (a[i] >= a[idx]) idx = i; b[i]..

https://www.acmicpc.net/problem/7774 #include #include #include using namespace std;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; vector mul1(n); vector mul2(m); for (int i = 0; i > mul1[i]; // a 플러그 -> b 콘센트 for (int i = 0; i > mul2[i]; // b 플러그 -> a 콘센트 sort(mul1.begin(), mul1.end()); sort(mul2.begin(), mul2.end())..

https://www.acmicpc.net/problem/11779 #include #include #include using namespace std;int MAX_SIZE = 1000000000;int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m; cin >> n >> m; vector>> g(n + 1); vector dst(n + 1, MAX_SIZE); vector route(n + 1); for (int i = 0; i > a >> b >> c; g[a].emplace_back(b, c); } int s, e; cin >> s >> ..