Skip to content

Commit 12323e9

Browse files
committed
[D2] Title: 지그재그 숫자, Time: 92 ms, Memory: 25,984 KB -BaekjoonHub
1 parent 8d8d511 commit 12323e9

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# [D2] 지그재그 숫자 - 1986
2+
3+
[문제 링크](https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PxmBqAe8DFAUq)
4+
5+
### 성능 요약
6+
7+
메모리: 25,984 KB, 시간: 92 ms, 코드길이: 533 Bytes
8+
9+
### 제출 일자
10+
11+
2025-09-26 17:42
12+
13+
14+
15+
> 출처: SW Expert Academy, https://swexpertacademy.com/main/code/problem/problemList.do
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import java.util.*;
2+
3+
class Solution
4+
{
5+
public static void main(String args[]) throws Exception
6+
{
7+
Scanner sc = new Scanner(System.in);
8+
int T;
9+
T=sc.nextInt();
10+
StringBuilder sb = new StringBuilder();
11+
12+
for(int test_case = 1; test_case <= T; test_case++)
13+
{
14+
int N = sc.nextInt();
15+
int sum = 0;
16+
for(int i=1; i<=N; i++){
17+
if(i%2 == 0 ) sum-=i;
18+
else sum+=i;
19+
}
20+
sb.append("#" + test_case+ " " +sum + "\n");
21+
}
22+
System.out.println(sb);
23+
}
24+
}

0 commit comments

Comments
 (0)