[BaekJoon] 16486번 - 운동장 한 바퀴 [Java][C++]
[BaekJoon] 16486번 - 운동장 한 바퀴 [Java][C++]
1. 문제 풀이
운동장의 둘레의 길이는 직사각형의 가로 두 변의 길이와 원의 둘레의 합과 같다.
2. 코드
1. 풀이 [Java]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.io.*;
public class Main {
static final double PI = 3.141592;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int d1 = Integer.parseInt(br.readLine());
int d2 = Integer.parseInt(br.readLine());
System.out.println(d1 * 2 + 2 * d2 * PI);
}
}
2. 풀이 [C++]
1
2
3
4
5
6
7
8
9
10
11
12
13
#include <bits/stdc++.h>
using namespace std;
double PI = 3.141592;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int d1, d2;
cin >> d1 >> d2;
cout << fixed << setprecision(6) << d1 * 2 + 2 * d2 * PI;
}
This post is licensed under CC BY 4.0 by the author.