시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 738 555 479 79.568%

문제

두 정수 n과 m이 주어졌을 때, 0 < a < b < n인 정수 쌍 (a, b) 중에서 (a2+b2+m)/(ab)가 정수인 쌍의 개수를 구하는 프로그램을 작성하시오.

입력

첫째 줄에 테스트 케이스의 개수 T가 주어진다. 각 테스트 케이스는 한 줄로 이루어져 있으며, n과 m이 주어진다. 두 수는 0보다 크고, 100보다 작거나 같다.

출력

각 테스트 케이스마다 문제의 조건을 만족하는 (a, b)쌍의 개수를 출력한다.

예제 입력 1

3
10 1
20 3
30 4

예제 출력 1

2
4
5
W3sicHJvYmxlbV9pZCI6IjkwOTQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMThcdWQ1NTlcdWM4MDEgXHVkNjM4XHVhZTMwXHVjMmVjIiwiZGVzY3JpcHRpb24iOiI8cD5cdWI0NTAgXHVjODE1XHVjMjE4IG5cdWFjZmMgbVx1Yzc3NCBcdWM4ZmNcdWM1YjRcdWM4NGNcdWM3NDQgXHViNTRjLCAwICZsdDsgYSAmbHQ7IGIgJmx0OyBuXHVjNzc4IFx1YzgxNVx1YzIxOCBcdWMzMGQgKGEsIGIpIFx1YzkxMVx1YzVkMFx1YzExYyAoYTxzdXA+MjxcL3N1cD4rYjxzdXA+MjxcL3N1cD4rbSlcLyhhYilcdWFjMDAgXHVjODE1XHVjMjE4XHVjNzc4IFx1YzMwZFx1Yzc1OCBcdWFjMWNcdWMyMThcdWI5N2MgXHVhZDZjXHVkNTU4XHViMjk0IFx1ZDUwNFx1Yjg1Y1x1YWRmOFx1YjdhOFx1Yzc0NCBcdWM3OTFcdWMxMzFcdWQ1NThcdWMyZGNcdWM2MjQuPFwvcD5cclxuIiwiaW5wdXQiOiI8cD5cdWNjYWJcdWM5ZjggXHVjOTA0XHVjNWQwIFx1ZDE0Y1x1YzJhNFx1ZDJiOCBcdWNmMDBcdWM3NzRcdWMyYTRcdWM3NTggXHVh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