전체 글
-
2의 보수를 이용한 음의정수 표현아무거나적어~ 2022. 1. 24. 18:33
2진법에서 -N(2)는 다음과 같이 구한다 $$ \begin{align*} -N(2) &= \text{(two's complement of N(2) on the base 2)}(\because \text{definition}) \\ &= \text{(one's complement of N(2) on the base 2)} + 1 \\ &= \sim N(2)+1 \end{align*} $$ 참고 r's complement number & (r-1)'s complement 요약 radix가 r인(r based) number system에서 N(r)의 자릿수를 d 라고 하자. 그러면 $$ \begin{align*} \text{(r-1)'s complement number of N(r)} &= r^{d}-N(r..
-
r's complement number & (r-1)'s complement아무거나적어~ 2022. 1. 23. 18:36
요약 radix가 r인(r based) number system에서 N(r)의 자릿수를 d 라고 하자. 그러면 $$ \begin{align*} \text{(r-1)'s complement number of N(r)} &= r^{d}-N(r)-1 \\ &= \underset{d}{\underbrace{(r-1)..(r-1)}}(r) \\ &= \text{maximun number of d digits which on the r based}-N(r) \\ \text{r's complement number of N(r)}&= r^{d}-N(r) \\ &= (1\underset{d}{\underbrace{00..00}}-N)r \\ &= \text{(r-1)'s complement number of N(r)}+..
-
1307-D, *1900코드포스 2022. 1. 7. 01:05
Problem - D - Codeforces codeforces.com 풀이 Xa+Yb 가 가장 클 때를 찾아야하는 이유는 Xa+Yb+1 이 노드 1부터 n 까지 (노트 a, b를 경유하는) 최단거리이기 때문 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 67 68 69 70 71 72 73 74 75 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i n ..
-
1307-C, *1500코드포스 2022. 1. 7. 01:02
Problem - C - Codeforces codeforces.com 풀이 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 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i s; map d; ooop(i, s.size()) d[s[i]-'a'].emplace_back(i); ll res = 0; for(const auto& [_, v]: d){ if(res
-
1622-C코드포스 2021. 12. 29. 22:46
Problem - C - Codeforces codeforces.com 풀이 tutorial 봤음 Educational Codeforces Round 120 Editorial - Codeforces codeforces.com 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 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i t; while(t--){ ll n, k; cin >> n >> k; vector a(n); for(auto& e: a) cin >> e; sort(all(a)); vector p(n+1..
-
1623-C코드포스 2021. 12. 29. 20:43
Problem - C - Codeforces codeforces.com 풀이 ※ 결과가 최소가 되게하는 최대 ~, 결과가 최대가 되게하는 최소 ~ 가 나오면 parametric search 고려해보자 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 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i t; while(t--){ int n; cin >> n; vector p(n); for(auto& e: p) cin..
-
1623-B코드포스 2021. 12. 29. 20:40
Problem - B - Codeforces codeforces.com 풀이 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 #include #define endl "\n" #define ooop(i, n) for(int i = 0; i t; while(t--){ int n; cin >> n; vector cnt(n); stack st; ooop(i, n){ int s, e; cin >> s >> e; st.push({s, e}); for(int j = s; j