전체 글(183)
-
C++ 입출력 속도 줄이기 !
나는 시간이없다. 빠르게 빠르게 해야하는데 입출력에서 시간을 낭비하면 안된다 ! cin / cout 으로 보통쓰는데, 이게 일반적으로 사용하면 느린갑다. ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 요걸 넣어주면 좀 더 빨라진다고하니, 한번 써볼까? 편법이라고하는데, 조건이 있다. 1) 싱글 스레드에서만 사용가능. 2) printf, scanf와 섞어서 사용하면 안됨 ! 근ㄷㅔ...코테에서도 이거 쓰나....? 쓰는거 못본거같은데 ... 흠... 찾아봐야겠군... #include using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout..
2022.08.03 -
C++ 빠르게 익히기.
C언어와 다른점 / 같은점 으로 우선 구분한다 !!! # 같은 점 기본적인 문법구조 : 조건문 ; if / else, switch 문 동일. 제어문 : for / while / break / continue 등등 은 동일하다. # 다른점. 1. print하는게 다르다. scanf 는 cin 으로 받고, cout 는 printf를 대신한다. 끝에 endl은 줄바꿈 + flush인데, 그거 말고 그냥 \n 으로 줄바꿈 하는게 낫다고한다. #include using namespace std; int main() { int N; int *arr = new int[2]; for(int i = 0 ; i > arr[i]; for(int i = 0 ; i >..
2022.08.03 -
유클리드 호제법 (Euclidean Algorithm) in C
유클리드 호제법은, 두 정수의 최대 공약수(Greatest Common Divisor)를 구하는 알고리즘 중 하나이다. a, b의 최대 공약수는, a/b를 나눈 나머지인 r과 b의 최대공약수와 같다는 성질에 따라, 재귀와 반복문을 통해 구현할 수 있다. * 최대 공약수 ( Greatest Common Divisor, GCD ) 두 개 이상의 수가 공통으로 갖고 있는 약수 중 가장 큰 ! 수. ex) 8의 약수 : 1, 2, 4, 8 12의 약수 : 1, 2, 3, 4, 6, 12 8과 12의 최대 공약수 : 4 * 최소 공배수 ( Least Common Multiple , LCM ) ex) 3의 배수 : 3, 6, 9, 12, 15 ... 5의 배수 : 5, 10, 15, 20 ... 3과 5의 최소 공..
2022.08.03 -
점근적 표기법 ( asymptotic notation)
* 점근적 표기법 이란? 상수 계수와 중요하지 않은 항목을 제거한것 ! 점근적 표기법에는 3가지가 있다. - big-ThetaΘ 표기법 > 보통 상수 인자와 낮은 차원의 항목은 생략하고 사용한다. 예를들어 시간이 6n^2 + 100n + 300이라고 가정하면, 계수인 6과 저차원 항목인 100n+300을 생략한 n^2만 실행시간으로 치는것이다. big-세타 표기법을 사용하는건, 실행시간에 대해 점근적으로 근접한 한계값이 있다고 표현하는것이다. 점근적으로 ! 라는 말을 쓰는 이유는, 큰 값의 n에 대해서만 적용되기 때문이다. 근접한 한계값이라는 말은, 위, 아래로 상수값 내에서 실행시간을 좁힐 수 있다는 뜻이다. https://ko.khanacademy.org/computing/computer-scienc..
2022.08.02 -
53. Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Example 2: Input: nums = [1] Output: 1 Example 3: Input: nums = [5,4,-1,7,8] Output: 23 Constraints: 1
2022.07.31 -
백준 - 13458 시험 감독 ( in C )
그 ~ 나마 쉬운문제.... 수학문제다. https://www.acmicpc.net/problem/13458 13458번: 시험 감독 첫째 줄에 시험장의 개수 N(1 ≤ N ≤ 1,000,000)이 주어진다. 둘째 줄에는 각 시험장에 있는 응시자의 수 Ai (1 ≤ Ai ≤ 1,000,000)가 주어진다. 셋째 줄에는 B와 C가 주어진다. (1 ≤ B, C ≤ 1,000,000) www.acmicpc.net #include int main() { int A[1000000+50000]; int n, b, c; unsigned long long int sum = 0; n = b = c = 0; scanf("%d", &n); for(int i = 0; i < n; i++) scanf("%d", &A[i]); ..
2022.07.31 -
Adjacency list in C
https://www.geeksforgeeks.org/graph-and-its-representations/ Graph and its representations - GeeksforGeeks A Computer Science portal for geeks. It contains well written, well thought and well explained computer science and programming articles, quizzes and practice/competitive programming/company interview Questions. www.geeksforgeeks.org
2022.07.30 -
pyyaml version upgrade 시 Command !
pyyaml 버전이 낮아서 설치가 제대로 안되서 Error 가 났다. 요때는 어째야하나!? https://stackoverflow.com/questions/49911550/how-to-upgrade-disutils-package-pyyaml How to upgrade disutils package PyYAML? I was trying to install chatterbot which has a dependency on PyYAML=3.12. In my Ubuntu machine installed PyYAML version is 3.11. So I used the following command to upgrade PyYAML: sudo -H pip3 ins... stackoverflow.com --ign..
2022.07.26 -
Ubuntu update 시 에러 날 경우!
update 를 하려니 바로 이런 에러가 뜨면서 update 가 안되더라. ( 먼저는 net-tools를 깔려고 했는데 안되서 update 를 한것.) 요렇게 404 Not Found 가 뜨고, Err 가 발생한다. 이 문제는 , 현재 사용하고 있는 우분투 버전의 업뎃 지원이 끝나, 해당 버전의 패키지 저장소가 이전 버전 아카이브 페이지인 old-release.ubuntu.com으로 이동되어 받아올 수 없는 경우라고 한다 ! sudo sed -i -re 's/([a-z]{2}\.)?archive.ubuntu.com|security.ubuntu.com/old-releases.ubuntu.com/g' /etc/apt/sources.list sudo apt-get update && sudo apt-get di..
2022.07.26