Skip to content

Instantly share code, notes, and snippets.

Created January 23, 2015 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/8a971b296e9715cfff2b to your computer and use it in GitHub Desktop.
Save anonymous/8a971b296e9715cfff2b to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# encoding: utf-8
from math import sqrt, ceil
def main():
def ans(r2, k):
count = 0
for x in xrange(int(ceil(sqrt(r2)))):
if sqrt(r2 - x*x).is_integer():
count += 4
if count > k:
return 'impossible'
return 'possible'
for _ in xrange(int(raw_input())):
print ans(*map(int, raw_input().split()))
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment