728x90
반응형
브루트포스 알고리즘 문제이다. Python3로 하면 시간 초과가 떠서 PyPy3로 제출했다.
from sys import stdin
for _ in range(int(stdin.readline())):
n, m = map(int, stdin.readline().split())
cnt = 0
for a in range(1, n-1):
for b in range(a+1, n):
if (a**2 + b**2 +m)%(a*b) == 0:
cnt += 1
print(cnt)
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 9288번 More Dice(python) (0) | 2021.02.20 |
---|---|
백준 알고리즘 9286번 Gradabase(python) (0) | 2021.02.20 |
백준 알고리즘 9085번 더하기(python) (0) | 2021.02.20 |
백준 알고리즘 8932번 7종 경기(python) (0) | 2021.02.20 |
백준 알고리즘 8815번 Test(python) (0) | 2021.02.20 |