-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from AlgoLeadMe/2-dhlee777
2-dhlee777
- Loading branch information
Showing
2 changed files
with
27 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include<iostream> | ||
using namespace std; | ||
long long int stair_num[101][11]; //nλ²μ§Έμ리μ mμ΄μμλ κ°λ₯ν κ³λ¨μμ | ||
int main(void) { | ||
ios_base::sync_with_stdio(false); | ||
cin.tie(NULL); | ||
int num; | ||
cin >> num; //첫째μ리μλ 0μ μ μΈνκ³ μ΄λ€μκ° μ€λ κ²½μ°μμλ 1μ΄λ€. | ||
for (int j = 1; j <= 9; j++) | ||
stair_num[1][j] = 1; | ||
for (int i = 2; i <=num; i++) { //μ΄λ€μ리μκ° 0μΌκ²½μ° κ·Έμ μ리μλ 1μ΄μ΄μΌνλ€. | ||
for (int j =0; j <10; j++) { | ||
if (!j) stair_num[i][j] = stair_num[i - 1][1]; | ||
stair_num[i][j] = (stair_num[i - 1][j - 1] + stair_num[i - 1][j + 1])%1000000000; | ||
} | ||
} | ||
long long int sum = 0; | ||
for (int j = 0; j < 10; j++) { //μ μΌ λ§μ§λ§μ리μ 0~9 κ° μ€λ κ²½μ°μμλ€μ κ°κ° λ€ λν΄μ€λ€. | ||
sum += stair_num[num][j]; | ||
} | ||
cout << sum%1000000000; | ||
return 0; | ||
} |