๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
SWEA

[SWEA] 2025. N์ค„ ๋ง์…ˆ

by JulesJ 2022. 5. 18.
728x90

2025. N์ค„ ๋ง์…ˆ - D1

 

์ฃผ์–ด์ง„ ์ˆซ์ž N๊นŒ์ง€ 1๋ถ€ํ„ฐ ๋”ํ•œ ๊ฐ’์„ ์ถœ๋ ฅํ•˜๋Š” ๋ฌธ์ œ์ด๋‹ค.

 

1๋ถ€ํ„ฐ N๊นŒ์ง€ ๋”ํ•œ ํ•ฉ์€ N(N+1)/2 ๋ผ๋Š” ๊ณต์‹์„ ์ด์šฉํ•œ๋‹ค.

 

(์ค‘ํ•™๊ต ๋•Œ ๋ฐฐ์› ๋˜ ๊ณต์‹์ธ ๊ฒƒ ๊ฐ™๋‹ค..?)

 

 

import java.util.Scanner;
import java.io.FileInputStream;

class Solution
{
	public static void main(String args[]) throws Exception
	{
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		System.out.println(N*(N+1)/2);
	}
}

 

 

๋ ๐Ÿง

๋Œ“๊ธ€