diff --git "a/dhlee777/dp/\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605.cpp" "b/dhlee777/dp/\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605.cpp" new file mode 100644 index 0000000..98b046e --- /dev/null +++ "b/dhlee777/dp/\352\265\254\352\260\204\355\225\251\352\265\254\355\225\230\352\270\2605.cpp" @@ -0,0 +1,23 @@ +#include +using namespace std; +int dp[1025][1025]; +int main(void) { + ios_base::sync_with_stdio(false); + cin.tie(NULL); + int size, cnt, start_row, start_col, end_row, end_col,temp; + cin >> size >> cnt; + + for (int i = 1; i <=size; i++) { + for (int j = 1; j <=size; j++) { + cin >> temp; + dp[i][j] = dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1] + temp; + } + } + for (int k = 0; k < cnt; k++) { + cin >> start_row >> start_col >> end_row >> end_col; + cout << dp[end_row][end_col] - dp[start_row - 1][end_col] - dp[end_row][start_col - 1] + dp[start_row - 1][start_col - 1]; + cout << "\n"; + } + + return 0; +} \ No newline at end of file