728x90
728x90
01 λ¬Έμ
02 μκ³ λ¦¬μ¦
- 0μΈ΅, 1μΈ΅, 2μΈ΅ β¦ μ λν΄ κ·μΉμ μ°Ύμλ€.
- 0μΈ΅μ iνΈ μΌ λ, iλͺ μ΄ μ΄κΈ° λλ¬Έμ λ°λ‘ κ°μ λ£μ΄μ£Όμκ³
- 1μΈ΅ μ΄νλΆν°λ νμ¬ μΈ΅ - 1μΈ΅μ μΈμμ λ°λ³΅λ¬ΈμΌλ‘ κ³μ°ν΄μ κ°μ λ£μ΄μ£Όμλ€.
03 μ½λ
#include "stdafx.h"
int main(void)
{
int i, j, jj;
int T, k, n;
int residents[15][15] = { 0, };
// Test case T
scanf_s("%d", &T);
while (T>0)
{
// 1 2 3
// 1 3 6
// 1 4 10
printf("# Test case %d\n", T);
scanf_s("%d", &k);
scanf_s("%d", &n);
// init zero floor
printf("0 μΈ΅ : ");
for (j = 0; j < n; j++)
{
residents[0][j] = j + 1;
printf("%d ", residents[0][j]);
}
printf("\n");
for (i = 1; i <= k; i++)
{
printf("%d μΈ΅ : ", i);
for (j = 0; j<n; j++)
{
int sum_residents = 0;
for (jj = 0; jj <= j; jj++)
sum_residents += residents[i-1][jj];
residents[i][j] = sum_residents;
printf("%d ", residents[i][j]);
}
printf("\n");
}
printf("%d\n", residents[k][n - 1]);
T--;
}
return 0;
}
728x90
728x90
'π Algorithm > μκ³ λ¦¬μ¦-Python' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[μκ³ λ¦¬μ¦] Day3 - 1260λ² DFSμ BFS (0) | 2018.08.08 |
---|---|
[μκ³ λ¦¬μ¦] Day2 - 2750λ² μ μ λ ¬νκΈ° (0) | 2018.08.04 |
[μκ³ λ¦¬μ¦] Day1 - κ΄νΈ (0) | 2018.08.04 |
[μκ³ λ¦¬μ¦] Day1 - μ€ν (0) | 2018.08.04 |
[μκ³ λ¦¬μ¦] Day1 - νμ (0) | 2018.08.04 |