문제 : https://www.acmicpc.net/problem/2028
[ 알고리즘풀이 ]
입력이 작으므로 if 문으로 단순 구현하면 된다.
#include<iostream>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int T;
cin >> T;
while (T--) {
int N;
bool check = false;
cin >> N;
if (N < 10) {
if ((N * N) % 10 == N)
check = true;
}
else if (N < 100) {
if ((N * N) % 100 == N)
check = true;
}
else if (N < 1000) {
if ((N * N) % 1000 == N)
check = true;
}
if (check)
cout << "YES\n";
else
cout << "NO\n";
}
}
'Problem Solving > BOJ' 카테고리의 다른 글
[BOJ] 2470 : 두 용액 - travelbeeee (0) | 2020.01.22 |
---|---|
[BOJ] 6986 : 절사평균 - travelbeeee (0) | 2020.01.22 |
[BOJ] 2033 : 반올림 - travelbeeee (0) | 2020.01.21 |
[BOJ] 15975 : 화살표 그리기 - travelbeeee (0) | 2020.01.21 |
[BOJ] 2551 : 두 대표 자연수 - travelbeeee (0) | 2020.01.20 |