Solutions of Square number - MarisaOJ: Marisa Online Judge

Solutions of Square number

Select solution language

Write solution here.


User Avatar HuyNguyenCong    Created at    0 likes

# $\textbf{SQUARE NUMBER}$ --- ## $\textbf{What is a square number?}$ $\text{A square number is a number that is the result of multiplying an integer by itself.}$ $\text{For example:}$ - $\text{16 is a square number because 4 $\times$ 4 = 16}$. - $\text{10 is not a square number because it is not the result of multiplying an integer by itself.}$ ## $\textbf{Full Code}$ ### $\text{C++}$ ```cpp #include <iostream> #include <cmath> // For sqrt() using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long a; cin >> a; long long temp = sqrt(a); if (temp * temp == a) cout << "YES"; else cout << "NO"; return 0; } ``` ### $\text{Python}$ ```python import math # For sqrt() a = int(input()) temp = int(math.sqrt(a)) if temp**2 == a: print("YES") else: print("NO") ```