Loading...
2024. 6. 20. 00:44

다이나믹 프로그래밍으로 구하는 복수순열2 - 주어진 개수의 알파벳들만으로 만들 수 있는 문자열의 개수

E - Alphabet Tiles (atcoder.jp) E - Alphabet TilesAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jp  대문자 알파벳 A,B,C,..,Z의 개수가 주어질때, 이들로 만들 수 있는 길이 1부터 k까지 모든 문자열의 개수를 구하는 문제 길이가 s일때, 각각 A,B,C,...,Z 문자가 a1,a2,a3,...,a26개 있다고 한다면.. 이들을 일렬로 배열하는 복수순열의 개수와 같으므로,  $$\frac{(a1+a2+a3+...+a26)!}{a1!a2!...a26!} = \frac{s!}{a1!..

2024. 6. 11. 02:28

문자열 수를 10진법으로 바꾸는 테크닉 - 배열에서 모든 가능한 순서쌍의 두 수를 이어붙여 만든 수의 합

D - Another Sigma Problem (atcoder.jp) D - Another Sigma ProblemAtCoder is a programming contest site for anyone from beginners to experts. We hold weekly programming contests online.atcoder.jp  배열 A의 모든 순서쌍 (A[i],A[j])에 대하여 f(A[i],A[j])를 A[i]A[j]라고 정의 예를 들어 f(10,1) = 101이고 f(3,14) = 314 i  예를 들어 3 14 15라면 (3,14), (3,15), (14,15) 3개의 순서쌍에 대해 314, 315, 1415가 있고 이들의 합은 2044 모든 순서쌍을 찾는 것은 기본적으로 $O(..

2024. 5. 18. 00:36

문자열 hashing function 빠르게 계산하는 방법

1. 왜 문자열의 hashing이 필요한가? https://deepdata.tistory.com/960 문자열 해싱(hashing) 기본 개념 배우기String Hashing - Algorithms for Competitive Programming (cp-algorithms.com) String Hashing - Algorithms for Competitive Programming String Hashing Hashing algorithms are helpful in solving a lot of problems. We want to solve the problem of comparing stringdeepdata.tistory.com  두 문자열 S1, S2가 서로 같은지 다른지 비교하고 싶을 때가 있..

2024. 5. 14. 23:32

python 리스트를 이용해 trie 구현하면서 개념 익히기

python에서는 trie가 class로 구현된 경우가 많아 꺼렸는데... 배열로 구현하는 법을 익혀서 기록해보기 https://deepdata.tistory.com/659 문자열 자료구조 Trie 알고리즘 기본기 배우기1. 문자열 단어 저장 'hello', 'hi', 'hey' 등을 저장하고자 할때, 생각할 수 있는 방법중 하나는 dictionary에 저장하는 것이다 d = {'hello':1, 'hi':1, 'hey':1} 단어를 key값으로 저장해두면, 특정 단어를 찾고자deepdata.tistory.com https://blog.encrypted.gg/1059 [실전 알고리즘] 0x1F강 - 트라이안녕하세요, 드디어 마지막 강이라니 가슴이 웅장해집니다. 마지막인만큼 난이도도 끝판왕일 수 있지만 개..

부분문자열 필수 트릭 - doubling cyclic substring trick

24597번: Reversibly Cyclic Strings (acmicpc.net)  문자열 s의 cyclic substring이라는 것은 s를 rotate했을때 부분문자열 t를 말한다. 'fatcat'에서 'atf'는 fatcat에서 왼쪽으로 1칸 rotate하면 atcatf인데 여기에 부분문자열로 있다 만약 s의 모든 부분문자열 t에 대하여 t를 뒤집은 것이 s의 cyclic substring이라면 s를 'Internally Reversibly Cyclic'이라고 정의한다. 주어진 s가 Internally Reversibly Cyclic인지 판단하는 문제  어떤 부분 문자열 t가 s의 cyclic substring이라는 것을 어떻게 알 수 있을까? 한칸 한칸씩 roate해서 판단해봐야할까? fatc..

2024. 4. 26. 00:11

python 문자열 간단하게 정리

문자형 데이터를 한글자씩 메모리 공간에 저장하는 시퀀스 자료형 리스트같이 슬라이싱, 인덱싱, 반복문 iteration 등이 가능 컴퓨터는 모든 데이터를 2진수로 저장하므로 문자를 2진수로 변환하는 표준규칙들이 존재함(utf-8,아스키코드 등)  1. 알면 좋을 법한 method rstrip(), lstrip(), strip() 오른쪽 ,왼쪽, 좌우 공백 제거   title() 띄어쓰기로 구분된 각 단어 첫글자를 대문자로 만들어서 반환   isdigit(), isalpha() 숫자로 이루어진것인지? 문자로 이루어진것인지?   ------------------------------------------------------------------------------------------------------..