Math 9

BAEKJOON 2702 - Sixth Grade Math

문제: https://www.acmicpc.net/problem/2702 문제In sixth grade, students are presented with different ways to calculate the Least Common Multiple(LCM) and the Greatest Common Factor (GCF) of two integers. The LCM of two integers a and b is the smallest positive integer that is a multiple of both a and b. The GCF of two non-zero integers aand b is the largest positive integer that divides both a and b..

BACKJOON 2681 - Rancher's Gift

문제: https://www.acmicpc.net/problem/2681 문제Rancher Joel has a tract of land in the shape of a convex quadrilateral that he wants to divide among his sons Al, Bob, Chas and Dave, who wish to continue ranching on their portions, and his daughter Emily, who wishes to grow vegetables on her portion.The center of the tract is most suitable for vegetable farming so Joel decides to divide the land by d..

BAEKJOON 1037 - 약수

문제: https://www.acmicpc.net/problem/1037 배열에 진짜 약수들을 담은 후 정렬을 하여 제일 작은 수와 제일 큰 수를 곱하면 답을 구할 수 있습니다. 123456789101112131415161718192021222324252627282930#include #include #include #include #include #include using namespace std; typedef long long ll; int main(){ int n; cin >> n; vector numbers; for (int i = 0; i > num; numbers.push_back(num); } sort(numbers.begin(), numbers.end()); ll ret = numbers..

BAEKJOON 1027 - 고층 건물

문제: https://www.acmicpc.net/problem/1027 처음에는 외적을 이용한 ccw 알고리즘으로 풀어봤는데(밑에 코드) 이상하게도 80% 정도에서 오답이 나와 간단하게 기울기를 구하는 방법으로 풀어봤습니다. 외적을 이용한 방법은 왜 틀렸는지 잘 모르겠네요;;; my solvingc++123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657#include #include #include #include #include #include using namespace std; int main(){ int n; cin >> n; vector heights; for..

BAEKJOON 1024 - 수열의 합

문제: https://www.acmicpc.net/problem/1024 1023번 문제에서 씨름하다가 이렇게 쉬운 문제를 만나니 상당히 반갑네요 ㅋ수열의 합은 간단하게 n(n+1)/2 를 응용해서 계산하고 l 이 최대 100이므로 시간 복잡도도 크게 신경안쓰고 풀 수 있었습니다. my solvingc++123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354#include #include #include #include #include using namespace std;typedef long long ll; ll sum(ll startNum, int n){ if (n % 2 == ..

BAEKJOON 1019 - 책 페이지

문제: https://www.acmicpc.net/problem/1019 우선 bruteForce 방법으로 몇 개의 숫자를 넣어 규칙을 찾아 문제를 풀었습니다.규칙은 99, 999, 999 그리고 199, 299, 399, 499 등을 넣어보면 발견할 수 있습니다. my solvingc++12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411..

BAEKJOON 1016 - 제곱 ㄴㄴ 수

문제: https://www.acmicpc.net/problem/1016 시간 복잡도를 줄이기위해 에라토스테네스의 체 방법을 사용해야했고, 공간 복잡도를 줄이기 위해 bit mask 방법과 주어진 최소값부터 에라토스테네스의 체를 적용하는 방법을 사용해 풀었습니다. my solvingc++12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061#include #include #include #include using namespace std;typedef long long ll; const ll MAX_N = 1000003;unsigned char sieve[(..

BAEKJOON 1004 - 어린왕자

문제: https://www.acmicpc.net/problem/1004 start 와 goal 지점을 둘러싸고 있는 행성의 개수를 구하는 방법으로 풀었습니다. 단, start 와 goal 둘 다 둘러싸고 있는 행성은 제하였습니다. my solvingc++12345678910111213141516171819202122232425262728293031323334353637383940414243444546#include #include #include using namespace std; struct Pos{ int x, y, r;}; bool whetherAEncloseB(Pos a, Pos b){ return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)..