We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8c01012 commit fd7e36aCopy full SHA for fd7e36a
2025-09-11/오창은/프로그래머스_두 원 사이의 정수 쌍
@@ -0,0 +1,20 @@
1
+class Solution {
2
+ public long solution(int r1, int r2) {
3
+ long answer = 0;
4
+
5
+ // x=1~r2까지 세기 (사분면 안쪽만)
6
+ for (int x = 1; x <= r2; x++) {
7
+ long maxY = (long)Math.floor(Math.sqrt((long)r2 * r2 - (long)x * x));
8
+ long minY = 0;
9
+ if (x < r1) {
10
+ minY = (long)Math.ceil(Math.sqrt((long)r1 * r1 - (long)x * x));
11
+ }
12
+ answer += (maxY - minY + 1);
13
14
15
+ // 4사분면 대칭
16
+ answer *= 4;
17
18
+ return answer;
19
20
+}
0 commit comments