문제 링크: 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
|
'USACO > Bronze' 카테고리의 다른 글
백준 11978 Mowing the Field (USACO January 2016 Bronze 3번) (0) | 2020.02.27 |
---|---|
백준 11977 Angry Cows (USACO January 2016 Bronze 2번) (0) | 2020.02.27 |
백준 11976 Promotion Counting (USACO January 2016 Bronze 1번) (0) | 2020.02.26 |
백준 11972 Contaminated Milk (USACO December 2015 Bronze 3번) (0) | 2020.02.26 |
백준 11971 속도 위반 (USACO December 2015 Bronze 2번) (0) | 2020.02.26 |