알고리즘

[알고리즘] 백준 6131 - 완전 제곱수 (C++)

blueberrysoda 2025. 1. 7. 23:59

[문제 링크] : https://www.acmicpc.net/problem/6131

#include <iostream>
using namespace std;

int main(){
    int N, Ans = 0;
    cin >> N;

    for(int i=1; i<=500; i++){
        for(int j=1; j<=500; j++){
            if(i * i == j * j + N){
                Ans++;
            }
        }
    }

    cout << Ans << "\n";
    return 0;
}