Skip to content

Commit

Permalink
CT_350
Browse files Browse the repository at this point in the history
  • Loading branch information
Jade-Good committed Jan 3, 2025
1 parent 6967f4e commit cdeb2ff
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions BOJ/Java/src/S5/Boj_32403_전구주기맞추기.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package S5;

import java.io.*;
import java.util.StringTokenizer;

public class Boj_32403_전구주기맞추기 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
StringTokenizer st = new StringTokenizer(br.readLine());

int N = Integer.parseInt(st.nextToken());
int T = Integer.parseInt(st.nextToken());

st = new StringTokenizer(br.readLine());
int min = 0;

for (int i = 0; i < N; i++) {
int time = Integer.parseInt(st.nextToken());
for (int j = 0; j < time; j++) {
if (T % (time - j) == 0 || T % (time + j) == 0) {
min += j;
break;
}
}
}

bw.write(Integer.toString(min));
bw.flush();
}
}

0 comments on commit cdeb2ff

Please sign in to comment.