Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions maths/Drone_Domain.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""Drone's Domain

Check failure on line 1 in maths/Drone_Domain.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (N999)

maths/Drone_Domain.py:1:1: N999 Invalid module name: 'Drone_Domain'
We call a square valid on a 2d coordinate plane if it satisfies the following conditions:

Check failure on line 2 in maths/Drone_Domain.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

maths/Drone_Domain.py:2:89: E501 Line too long (89 > 88)

Area of the square should be equal to 1.
All vertices of the square have integer coordinates.
All vertices of square lie inside or on the circle of radius r, centered at origin.
Given the radius of circle r, count the number of different valid squares. Two squares are different if atleast one of the vertices of first square is not a vertex of second square.

Check failure on line 7 in maths/Drone_Domain.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

maths/Drone_Domain.py:7:89: E501 Line too long (181 > 88)

Input Format
The first line contains the integer r, the radius of the circle.

Constraints
1 <= r <= 2 * 10^5
Use a 64-bit integer type (like long long in C++ or long in Java) for sum calculations to prevent overflow.

Check failure on line 14 in maths/Drone_Domain.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

maths/Drone_Domain.py:14:89: E501 Line too long (107 > 88)

Output Format
Print the number of different squares in this circle of radius r.

Sample Input 1
Sample Output 0"""

# Title: Count Axis-Aligned Unit Squares in Circle
# Description: Counts the number of squares with area 1, integer vertices, fully inside a circle of radius r.

Check failure on line 23 in maths/Drone_Domain.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

maths/Drone_Domain.py:23:89: E501 Line too long (109 > 88)

import sys
import math

Check failure on line 26 in maths/Drone_Domain.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (F401)

maths/Drone_Domain.py:26:8: F401 `math` imported but unused

Check failure on line 26 in maths/Drone_Domain.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

maths/Drone_Domain.py:25:1: I001 Import block is un-sorted or un-formatted

r=int(sys.stdin.readline())
count=0
for x in range(-r,r):
for y in range(-r,r):
# Check all four vertices are inside the circle
if (x*x+y*y<=r*r and
(x+1)*(x+1)+y*y<=r*r and
x*x+(y+1)*(y+1)<=r*r and
(x+1)*(x+1)+(y+1)*(y+1)<=r*r):
count += 1

print(count)
Loading