USACO/Bronze
백준 11970 Fence Painting (USACO December 2015 Bronze 1번)
ssam..
2020. 2. 26. 00:13
문제 링크: https://www.acmicpc.net/problem/11970
11970번: Fence Painting
Several seasons of hot summers and cold winters have taken their toll on Farmer John's fence, and he decides it is time to repaint it, along with the help of his favorite cow, Bessie. Unfortunately, while Bessie is actually remarkably proficient at paintin
www.acmicpc.net
fence라는 배열에 a에서 b-1까지, c에서 d-1까지 1을 입력하고, 1의 갯수를 카운트함.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, fence[101];
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> a >> b >> c >> d;
for(int i = a; i < b; i++) fence[i] = 1;
for(int i = c; i < d; i++) fence[i] = 1;
int ans = 0;
for(int i = 0; i <= 100; i++) ans += fence[i];
cout << ans << '\n';
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
|