알고리즘

[알고리즘] 백준 9094 - 수학적 호기심 (C++)

blueberrysoda 2024. 11. 25. 23:34

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

#include <iostream>
using namespace std;

int T, Cnt, N, M;

int main(){
    cin >> T;
    while(T--){
        Cnt = 0;
        cin >> N >> M;
        for(int i=1; i<N; i++){
            for(int j=i+1; j<N; j++){
                if(((i * i + j * j + M) % (i * j)) == 0){
                    Cnt++;
                }
            }
        }
        cout << Cnt << "\n";
    }
    return 0;
}