문제
https://www.acmicpc.net/problem/6887
해결방법
입력받은 숫자를 sqrt 함수를 이용하여 제곱근을 구하고 앞에 (int)를 붙여 정수로 만들어 출력하면 된다.
코드
#include<iostream>
#include<cmath>
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
cout << "The largest square has side length "<<(int)sqrt(n)<<'.';
return 0;
}
'PS > 백준' 카테고리의 다른 글
[C++] 백준 6825: Body Mass Index (0) | 2023.05.14 |
---|---|
[C++] 백준 25784: Easy-to-Solve Expressions (0) | 2023.05.13 |
백준 18698: The Walking Adam (0) | 2023.05.11 |
[C++] 백준 5300: Fill the Rowboats! (0) | 2023.05.10 |
[C++] 백준 5357: Dedupe (0) | 2023.05.09 |
댓글