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 31 32 33 34 | #include <cstdio> using namespace std; int arr[100][100]; void input_arr( int N) { for ( int i=0; i<N; i++) for ( int j=0; j<N; j++) scanf ( "%d" ,&arr[i][j]); } int main() { for ( int T=1; T<=10; T++) { int c; scanf ( "%d" ,&c); input_arr(c); int cnt=0; for ( int j=0; j<c; j++) { int tmp_mag=2; for ( int i=0; i<c; i++) { if (arr[i][j]==1) tmp_mag=1; if (arr[i][j]==2 && tmp_mag==1) { tmp_mag=2; cnt++; } } } printf ( "#%d %d\n" ,T,cnt); } } |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
171104_1225_암호생성기 (0) | 2017.11.04 |
---|---|
171103_1221_GNS (0) | 2017.11.03 |
171103_거듭제곱 (0) | 2017.11.03 |
171103_14503_로봇청소기(틀림) (0) | 2017.11.03 |
171103_숫자골라내기 (0) | 2017.11.03 |
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 31 32 33 34 | #include <cstdio> using namespace std; int arr[100][100]; void input_arr( int N) { for ( int i=0; i<N; i++) for ( int j=0; j<N; j++) scanf ( "%d" ,&arr[i][j]); } int main() { for ( int T=1; T<=10; T++) { int c; scanf ( "%d" ,&c); input_arr(c); int cnt=0; for ( int j=0; j<c; j++) { int tmp_mag=2; for ( int i=0; i<c; i++) { if (arr[i][j]==1) tmp_mag=1; if (arr[i][j]==2 && tmp_mag==1) { tmp_mag=2; cnt++; } } } printf ( "#%d %d\n" ,T,cnt); } } |
'알고리즘 문제 풀이 > 1DP_과제(~180615)' 카테고리의 다른 글
171104_1225_암호생성기 (0) | 2017.11.04 |
---|---|
171103_1221_GNS (0) | 2017.11.03 |
171103_거듭제곱 (0) | 2017.11.03 |
171103_14503_로봇청소기(틀림) (0) | 2017.11.03 |
171103_숫자골라내기 (0) | 2017.11.03 |