※ 글쓴이는 취미로 코딩을 익혀보는 사람이라 정확하지 않은 내용을 담고 있을 수 있다 ※
이번에 볼 문제는 백준 25991번 문제인 Lots of Liquid이다.
문제는 아래 링크를 확인하자.
https://www.acmicpc.net/problem/25991
25991번: Lots of Liquid
You work at a warehouse that sells chemical products, where somebody just placed an order for all the Boron Acetate Phosphoric Carbonate (BAPC) that you have in store. This liquid is stored in many separate lots, in cube-shaped containers, but your client
www.acmicpc.net
각 lot의 부피는 lot의 한 변의 길이의 세제곱으로 구할 수 있다. 전제 부피의 합을 구한 뒤 그 값의 세제곱근을 구하는 것으로 문제를 해결하자.
cmath헤더의 cbrt 함수를 이용하면 세제곱근 값을 구할 수 있다. (cube root)
아래는 제출한 소스코드이다.
#include <iostream>
#include <cmath>
using namespace std;
typedef long double ld;
int N;
ld total;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cout << fixed;
cout.precision(10);
cin >> N;
while (N--) {
ld x; cin >> x;
total += x * x * x;
}
cout << cbrt(total);
}
728x90
'BOJ' 카테고리의 다른 글
[BOJ 17637 // C++] Count Squares (0) | 2022.11.17 |
---|---|
[BOJ 25972 // C++] 도미노 무너트리기 (0) | 2022.11.16 |
[BOJ 25973 // C++] 어지러운 트리 (0) | 2022.11.15 |
[BOJ 1748 // C++] 수 이어 쓰기 1 (0) | 2022.11.14 |
[BOJ 25965 // C++] 미션 도네이션 (0) | 2022.11.14 |