일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- graph
- 30870
- 코딩
- 16202
- backtracking #codetree #디버깅 #삼성코테
- BOJ
- C++
- 20117
- 최소 #공배수 #최대 #공약수 #유클리드 #호제법 #lcm #gcd #c++ #boj #3343 #백준 #장미
- 사이클 없는 그래프
- 3D #Reconstruction #computer #vision #volume #metric #tsdf #kinect #fusion
- 호반우 상인
- 백준
- 줄어드는수
- N번째큰수
- 쌤쌤쌤
- 투포인터 #백준 #boj #20922 #22862
- 레드아보
- 백준 #다익스트라 #dijkstra #9370 #c++
- 진법변환 #2to10 #10to2 #이진법 #십진법 #변환 #bitset #c++
- 22869
- boj #백준
- hcpc
- 1174
- 3343
- 이분탐색 #dp #11053
- graph #최단경로
- LIS #가장긴증가하는부분수열 #
- c++ #boj #
- c++ #입출력 #속도 #ios #sync_with_stdio #cin #cout #tie
- Today
- Total
목록알고리즘 연습 (105)
hyunjin
소수 찾기 백준 소수 찾기 1978 소스 코드 #include using namespace std; int main(){ int n,num,ans; cin>>n; ans = n; while(n-- ){ cin>>num; if(num
10진 -> n 진법 백준11005 소스코드 #include using namespace std; int main(){ int n,b; string ans; cin>> n>>b; while(n>0){ char c = (n%b)s >>n; cout>n; int len = n.size(); if( len %3 == 1) cout=0){ ans += '1'; tmp -=2; } else ans += '0'; if(tmp-1>=0){ ans += '1'; tmp -=1; } else ans += '0'; (i==0) ? cout
백준 2609 최대공약수 최소공배수 소스 코드 직접 구현 #include using namespace std; int GCD(int a,int b){ return b? GCD(b,a%b) : a; } int main(){ int a,b,g; scanf("%d %d",&a,&b); g = (a>b) ? GCD(a,b) : GCD(b,a); printf("%d\n%d",g,a*b/g); return 0; } gcd 라이브러리 사용 int main(){ int a,b; cin>>a>>b; cout B, cout
백준 10430 바로가기 문제 자체는 쉽지만 다음에 풀 문제들을 위해 유클리드 호제법과 함께 같이 기록해놓는다. 소스코드 #include using namespace std; int main(){ int a,b,c; scanf("%d %d %d",&a,&b,&c); printf("%d\n%d\n%d\n%d", (a+b)%c, ((a%c)+(b%c))%c, (a*b)%c, ((a%c)*(b%c))%c ); return 0; } 유클리드 호제법이란? 두 수의 최대 공약수를 구하는 알고리즘의 하나. 2개 자연수 a, b ( a > b )에 대해 a를 b로 나눈 나머지를 r이라 하면, a와 b의 최대공약수는 b와 r의 최대공약수와 같다. 또 다시 b , r 에 대해 b를 r로 나눈 나머지 r' 을 가지고 위의 ..
백준 알파벳 개수 10808 소스 코드 - 소문자 아스키 #include using namespace std; int main(){ int i=0,alpha[26]={0,}; string word; cin>>word; //for(cin>>word ; word[i] ;) alpha[ word[i++]-'a']++; // 위에 이렇게도 가능 for(auto c : word)alpha[c-'a']++; for(auto e : alpha) cout
백준 10809 바로가기 문자열을 입력받고 각 문자에 각 알파벳에 대해 문자열에서 처음 나오는 위치를 출력하는 문제다. 위치 찾는 방법을 find 활용해서 풀어보자. 소스코드1 #include using namespace std; int main(){ string w; cin>>w; // 기본 풀이 int a[26]; memset(a,-1,sizeof(a)); for(int i = -1; w[++i] ;) if(a[w[i]-'a'] < 0) a[w[i]-'a'] = i; for(auto e : a) cout
백준 9012 바로가기 더 쉽고 메모리, 시간 적게 사용되는 코드로 바꾸고 있다. 소스 코드 1 - 배열 활용 #include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int N; string s; cin >>N; while(N--){ cin>>s; int arr[2]={0,}; for(char c : s){ arr[int(c-'(')]++; if(arr[0]
백준 합분해(2225) 풀이 K \ N 0 1 2 3 4 0 0 0 0 0 0 1 1 1 1 1 1 2 1 2 3 4 3 1 3 6 4 1 4 10 5 1 5 15 점화식 D[K][N] = D[K][N-1] + D[N-1][N] 소스 코드 #include #define Moduler 1000000000 using namespace std; int main (){ int K,N; long long dp[201][201]={0,}; // k n scanf("%d %d",&N,&K); for(int i = 0; i