Pewarta Proxy

📋 Server Request & Proxy Logs

Loading active proxy settings...
Developed by Khairul Adha (adhexa.id)
Mengambil log server...

⚙️ Pengaturan Proxy Target

Skip to content

Commit 1c4985c

Browse files
committed
.
1 parent a298c86 commit 1c4985c

3 files changed

Lines changed: 107 additions & 0 deletions

File tree

‎python/SWAcademy/basic1.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 피보나치수열 푸는 3가지 방법
2+
# 1. 재귀
3+
# 2. 반복
4+
# 3. 동적 계획법
5+
6+
'''
7+
# 재귀
8+
수학적 귀납법
9+
1) n이 0일때 풀 수 있음
10+
2) n-1에서 문제를 풀 수 있으면, n에서도 문제를 풀 수 있다.
11+
-> 모든 가능한 n에 대해 문제를 풀 수 있다.
12+
'''
13+
14+
# 부분 문제가 동일한 경우
15+
# 정확성 증명 및 시간 복잡도 계산
16+
17+
'''
18+
두 집합 A와 B에 대해 A가 B의 부분집합임을 증명한다는 것은 A의 임의의 원소가 B에 포함됨을 보이는 것과 같다.
19+
20+
두 집합 A와 B가 같다는 것을 증명하기 위해서는 A가 B의 부분 집합이고, B가 A의 부분집합임을 증명하면 된다.
21+
'''

‎python/SWAcademy/combination.cpp‎

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#include <stdio.h>
2+
#define MAX_STRING_LENGH 10
3+
4+
int stackTop = 0;
5+
char combinationStack[MAX_STRING_LENGH];
6+
7+
void swap(char *x, char *y) {
8+
char temp;
9+
temp = *x;
10+
*x = *y;
11+
*y = temp;
12+
}
13+
14+
void permutation(char *str, int l, int r) {
15+
if (l==r) {
16+
printf("%s\n", str);
17+
} else {
18+
for (int i=1; i<=r; i++) [
19+
swap((str+l), (str+i));
20+
permutation(str, l+1, r);
21+
swap((str+l), (str+i)); // backtrack
22+
]
23+
}
24+
}
25+
26+
void pop()
27+
{
28+
    combinationStack[--stackTop] = '\0';
29+
}
30+
 
31+
32+
void combination(const char* str, int length, int offset, int k)
33+
{
34+
if (k == 0)
35+
{
36+
printf("%s\n", combinationStack);
37+
return;
38+
}
39+
for (int i = offset; i <= length - k; ++i)
40+
{
41+
push(str[i]);
42+
combination(str, length, i+1, k-1);
43+
pop();
44+
}
45+
}
46+
47+
int main()
48+
{
49+
int N, K, T;
50+
char str[MAX_STRING_LENGTH];
51+
scanf("%d", &T);
52+
53+
for (int test_case = 1; test_case <= T; test_case++)
54+
{
55+
scanf("%s%d%d", str, &N, &K);
56+
str[N] = 0;
57+
printf("#%d\n", test_case);
58+
59+
permutation(str, 0, N-1);
60+
combination(str, N, 0, K);
61+
}
62+
63+
return 0;
64+
}

‎python/SWAcademy/combination.py‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
@profile
2+
def solution():
3+
# x, y, z = 100
4+
count = 0
5+
for x in range(1, 100):
6+
for y in range(1, 100):
7+
if x + y >= 100:
8+
break
9+
for z in range(1, 100):
10+
if x+y+z == 100:
11+
count += 1
12+
print(f'({x}, {y}, {z})')
13+
if x+y+z > 100:
14+
break
15+
print(count)
16+
17+
if __name__ == '__main__':
18+
solution()
19+
20+
# 전사함수 개수 찾기
21+
# Y의 사이빈틈을 기준으로 찾으면 된다.
22+
# m -> n 전사함수

0 commit comments

Comments
 (0)