Submission #61796454


Source Code Expand

Copy
import java.util.*;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int R = in.nextInt();
long count = 0;
int limit = R;
for (int i = -limit; i <= limit; i++) {
for (int j = -limit; j <= limit; j++) {
double x1 = i - 0.5, y1 = j - 0.5;
double x2 = i - 0.5, y2 = j + 0.5;
double x3 = i + 0.5, y3 = j - 0.5;
double x4 = i + 0.5, y4 = j + 0.5;
if (isInsideCircle(x1, y1, R) && isInsideCircle(x2, y2, R) &&
isInsideCircle(x3, y3, R) && isInsideCircle(x4, y4, R)) {
count++;
}
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
import java.util.*;

public class Main{

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int R = in.nextInt();

        long count = 0;
        int limit = R; 

        for (int i = -limit; i <= limit; i++) {
            for (int j = -limit; j <= limit; j++) {
                double x1 = i - 0.5, y1 = j - 0.5;
                double x2 = i - 0.5, y2 = j + 0.5;
                double x3 = i + 0.5, y3 = j - 0.5;
                double x4 = i + 0.5, y4 = j + 0.5;
                if (isInsideCircle(x1, y1, R) && isInsideCircle(x2, y2, R) &&
                    isInsideCircle(x3, y3, R) && isInsideCircle(x4, y4, R)) {
                    count++;
                }
            }
        }

        System.out.println(count);
    }

    private static boolean isInsideCircle(double x, double y, int R) {
        return x * x + y * y <= R * R;
    }
}

Submission Info

Submission Time
Task D - Squares in Circle
User pitch_black
Language Java (OpenJDK 17)
Score 0
Code Size 934 Byte
Status TLE
Exec Time 2213 ms
Memory 38036 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 4
TLE × 21
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 69 ms 37812 KB
00_sample_01.txt AC 68 ms 37732 KB
00_sample_02.txt AC 68 ms 37756 KB
01_random_00.txt TLE 2209 ms 37888 KB
01_random_01.txt TLE 2209 ms 38036 KB
01_random_02.txt TLE 2209 ms 37760 KB
01_random_03.txt TLE 2209 ms 37752 KB
01_random_04.txt TLE 2209 ms 37824 KB
01_random_05.txt TLE 2209 ms 37680 KB
01_random_06.txt TLE 2209 ms 37748 KB
01_random_07.txt TLE 2209 ms 37704 KB
01_random_08.txt TLE 2209 ms 37872 KB
01_random_09.txt TLE 2209 ms 37732 KB
01_random_10.txt TLE 2209 ms 37996 KB
01_random_11.txt TLE 2209 ms 37832 KB
01_random_12.txt TLE 2213 ms 37992 KB
01_random_13.txt TLE 2212 ms 37936 KB
01_random_14.txt TLE 2209 ms 37880 KB
01_random_15.txt TLE 2209 ms 38012 KB
01_random_16.txt TLE 2209 ms 38028 KB
01_random_17.txt TLE 2209 ms 37856 KB
01_random_18.txt TLE 2209 ms 37684 KB
01_random_19.txt TLE 2209 ms 37884 KB
01_random_20.txt AC 69 ms 37808 KB
01_random_21.txt TLE 2209 ms 37704 KB


2025-03-25 (Tue)
21:46:10 +00:00