Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion caucsejunseo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@
| 6μ°¨μ‹œ | 2025.04.06 | 큐 | [μ•΅λ¬΄μƒˆ](https://www.acmicpc.net/problem/14713)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/23|
| 7μ°¨μ‹œ | 2025.04.10 | 그리디 | [ν΄λ¦¬μ˜€λ―Έλ…Έ](https://www.acmicpc.net/problem/1343)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/28|
| 8μ°¨μ‹œ | 2025.04.11 | μ—°κ²°λ¦¬μŠ€νŠΈ| [ν‚€λ‘œκ±°](https://www.acmicpc.net/problem/5397)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/30|
| 9μ°¨μ‹œ | 2025.04.30 | λ¬Έμžμ—΄ | [λ“£λ³΄μž‘](https://www.acmicpc.net/problem/1764)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/35|
| 9μ°¨μ‹œ | 2025.04.30 | λ¬Έμžμ—΄ | [λ“£λ³΄μž‘](https://www.acmicpc.net/problem/1764)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/35|
|10μ°¨μ‹œ| 2025.05.05 | DP | [1λ‘œλ§Œλ“€κΈ°](https://www.acmicpc.net/problem/1463)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/38|
|11μ°¨μ‹œ| 2025.05.07 | DP | [1,2,3λ”ν•˜κΈ°](https://www.acmicpc.net/problem/9095)|https://github.com/AlgoLeadMe/AlgoLeadMe-13/pull/41|

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#define MIN(a,b) ((a) < (b) ? (a) : (b))
#define MAX 1000001


int main() {

int N = 0;
scanf("%d", &N);

int* dp = (int*)malloc(sizeof(int) * MAX);

if (dp == NULL) {
printf("λ©”λͺ¨λ¦¬ ν• λ‹Ή μ‹€νŒ¨!\n");
return 1;
}

dp[1] = 0;

for (int i = 2; i < N + 1; i++)
{
dp[i] = dp[i - 1] + 1;

if (i % 3 == 0)
{
dp[i] = MIN(dp[i], dp[i / 3] + 1);
}
if (i % 2 == 0)
{
dp[i] = MIN(dp[i], dp[i / 2] + 1);
}
}

printf("%d", dp[N]);

return 0;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

int main()
{
int T = 0;
scanf("%d", &T);

int dp[11];

dp[1] = 1;
dp[2] = 2;
dp[3] = 4;

int* count = (int*)malloc(sizeof(int) * T);
int* answer = (int*)malloc(sizeof(int) * T);

for (int i = 0; i < T; i++)
{
//값을 λ„˜κ²¨μ•Ό ν•΄μ„œ &μ“°κΈ°
scanf("%d", &count[i]);

if (count[i] < 4)
{
answer[i] = dp[count[i]];
}
else if (count[i] >= 4)
{
for (int k = 4; k <= count[i]; k++)
{
dp[k] = dp[k - 1] + dp[k - 2] + dp[k - 3];
}
answer[i] = dp[count[i]];
}
}

for (int i = 0; i < T; i++)
{
printf("%d\n", answer[i]);
}



return 0;
}
/* 1
* λ…Έκ°€λ‹€
1
1

2
1 1
2

3
1 1 1
1 2
2 1
3

4
1 1 1 1
1 1 2
1 2 1
2 1 1
2 2
1 3
3 1

5
1 1 1 1 1
1 1 1 2
1 1 2 1
1 2 1 1
2 1 1 1
1 2 2
2 1 2
2 2 1
1 1 3
1 3 1
3 1 1
2 3
3 2

6
1 1 1 1 1 1
1 1 1 1 2
1 1 1 2 1
1 1 2 1 1
1 2 1 1 1
2 1 1 1 1
1 1 2 2
1 2 1 2
1 2 2 1
2 1 1 2
2 1 2 1
2 2 1 1
2 2 2
1 1 1 3
1 1 3 1
1 3 1 1
3 1 1 1
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
3 3


1 2 4 7 13 24*/