Notice
Recent Posts
Recent Comments
- Today
- Total
01-11 05:49
Tags
- μλ°μμ μ
- Graph
- MST
- BFS
- 벨λ§ν¬λ
- λ°±μλ
- tree
- database
- μλ°
- array
- dp
- μλ£κ΅¬μ‘°
- PS
- λ°±μ€
- λ€μ΅μ€νΈλΌ
- OOP
- Algorithm
- λ°μ΄ν°λ² μ΄μ€
- spring
- java
- ꡬν
- μ‘Έμ μν
- 그리λ
- leetcode
- μμμ λ ¬
- λ¬Έλ²
- CS
- μΈν΄
- pytorch
- νλ‘κ·Έλλ¨Έμ€
Link
Partially Committed
[CH01] ν¬ν¬μΈν° λ³Έλ¬Έ
728x90
λ°μν
SMALL
Algorithm || DataStructure
#02. ν¬ν¬μΈν°
Date : 2022/09/09
νλ¦° λ΄μ©μ΄ μμ μ, μ§μ ν΄μ£Όμλ©΄ κ°μ¬νκ² μ΅λλ€!
[λ°±μ€ 2018] μλ€μν©5
https://www.acmicpc.net/problem/2018
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken()); // μ μ N μ
λ ₯ λ°μ
int sum = 1;
int count = 1;
int s = 1, e = 1;
while(e!=n){
if(sum==n){
e++;
sum += e;
count++;
}
else if(sum>n) {
sum -=s;
s++;
}
else {
e++;
sum +=e;
}
}
System.out.println(count);
}
}
[λ°±μ€ 1940] μ£Όλͺ½μ λͺ λ Ή
https://www.acmicpc.net/problem/1940
(μμ±μ€)
References
1. http://www.yes24.com/Product/Goods/108571508
728x90
λ°μν
LIST
'π₯ Algorithm || λ¬Έμ νμ΄ > PS' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[LEETCODE] 1491. Average Salary Excluding the Minimum and Maximum Salary (0) | 2022.10.09 |
---|---|
[LEETCODE] 1523. Count Odd Numbers in an Interval Range (0) | 2022.10.09 |
[CH01] ꡬκ°ν© (0) | 2022.09.09 |
[μ°μ μμν] νλ¦°ν° (μλ°) (0) | 2022.09.04 |
[ν] κΈ°λ₯κ°λ° (JAVA) (0) | 2022.09.03 |
Comments