Skip to content

Commit b83f3de

Browse files
committed
1020
1 parent 59ac4a7 commit b83f3de

File tree

10 files changed

+217
-26
lines changed

10 files changed

+217
-26
lines changed

.idea/modules.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BOJ/gold/BOJ1759/BOJ1759.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

BOJ/gold/BOJ1759/src/Main.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
import java.util.*;
5+
6+
public class Main {
7+
static int N;
8+
static int L;
9+
static int count;
10+
11+
public static void main(String[] args) throws IOException {
12+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
13+
StringTokenizer st = new StringTokenizer(br.readLine());
14+
N=Integer.parseInt(st.nextToken());
15+
L=Integer.parseInt(st.nextToken());
16+
count=0;
17+
String s= br.readLine();
18+
String [] alpa =s.split(" ");
19+
Arrays.sort(alpa);
20+
String [] visited = new String[N];
21+
FindPassword(alpa, visited,0, 0);
22+
23+
24+
25+
}
26+
27+
private static void FindPassword(String[] alpa,String [] visited, int r, int tmp) {
28+
if(r==N){
29+
int vowels =0;
30+
int consonants=0;
31+
String str= String.join("",visited);
32+
for (int i=0; i<visited.length;i++){
33+
if(visited[i].equals("a")||visited[i].equals("e")||visited[i].equals("i")||visited[i].equals("o")||visited[i].equals("u")){
34+
vowels++;
35+
}else {
36+
consonants++;
37+
}
38+
}
39+
if(vowels>=1 && consonants>=2 ){
40+
System.out.println(str);
41+
}
42+
43+
return;
44+
}
45+
for (int i = tmp; i < L; i++) {
46+
visited[r]=alpa[i];
47+
FindPassword(alpa, visited, r+1,i+1);
48+
49+
50+
51+
}
52+
}
53+
}

BOJ/silver/BOJ1476/src/Main.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,10 @@ public static void main(String[] args) throws IOException {
1414
int E_MAX=15;
1515
int S_MAX=28;
1616
int M_MAX=19;
17-
//E와 S의 최대공약수를 구한다.
18-
int gcdTmp=GCD(E_MAX,S_MAX);
19-
//E와 S의 최소공배수를구한다.
20-
int lcmTmp=(E_MAX*S_MAX)/gcdTmp;
21-
//구한 최대공약수와 M의 최대공약수를 구한다.
22-
int gcd=GCD(lcmTmp,M_MAX);
23-
//구한 최소공배수와 M의 최소공배수를 구한다.
24-
int lcd=(lcmTmp*M_MAX)/gcd;
2517

2618

2719
int cacYear=E;
28-
while (cacYear<=lcd){
20+
while (true){
2921
if((cacYear-S)%S_MAX==0 &&(cacYear-M)%M_MAX==0 ){
3022
break;
3123
}
@@ -34,23 +26,6 @@ public static void main(String[] args) throws IOException {
3426
System.out.println(cacYear);
3527

3628

37-
38-
39-
40-
41-
42-
43-
44-
}
45-
46-
47-
private static int GCD(int a, int b) {
48-
int now= a%b;
49-
if(now==0){
50-
return b;
51-
}else{
52-
return GCD(b,now);
53-
}
5429
}
5530

5631
}

BOJ/silver/BOJ14889/BOJ14889.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

BOJ/silver/BOJ14889/src/Main.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
import java.util.Arrays;
5+
import java.util.StringTokenizer;
6+
7+
public class Main {
8+
static int minv = Integer.MAX_VALUE;
9+
10+
public static void main(String[] args) throws IOException {
11+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
12+
int N = Integer.parseInt(br.readLine());
13+
StringTokenizer st;
14+
int[][] Link = new int[N][N];
15+
int[] Team = new int[N];
16+
for (int i = 0; i < N; i++) {
17+
st = new StringTokenizer(br.readLine());
18+
int j = 0;
19+
while (st.hasMoreTokens()) {
20+
Link[i][j] = Integer.parseInt(st.nextToken());
21+
j++;
22+
}
23+
}
24+
FindTeam(Link, Team, N, 0, 0);
25+
System.out.println(minv);
26+
27+
28+
}
29+
30+
private static void FindTeam(int[][] link, int[] team, int n, int r, int idx) {
31+
if (r == n / 2) {
32+
FindIndex(team, link);
33+
return;
34+
}
35+
for (int i = idx; i < n; i++) {
36+
if (team[i] == 0) {
37+
team[i] = 1;
38+
FindTeam(link, team, n, r + 1, i + 1);
39+
team[i] = 0;
40+
}
41+
42+
43+
}
44+
}
45+
46+
private static void FindIndex(int[] team, int[][] link) {
47+
int teamA = 0;
48+
int teamB = 0;
49+
for (int i = 0; i < team.length; i++) {
50+
for (int j = i + 1; j < team.length; j++) {
51+
if (team[i] == 1 && team[j] == 1) {
52+
teamA += (link[i][j] + link[j][i]);
53+
54+
} else if (team[i] == 0 && team[j] == 0) {
55+
teamB += (link[i][j] + link[j][i]);
56+
}
57+
}
58+
59+
}
60+
int cac=Math.abs(teamA - teamB);
61+
minv=Math.min(minv,cac);
62+
}
63+
64+
65+
}

BOJ/silver/BOJ1748/BOJ1748.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

BOJ/silver/BOJ1748/src/Main.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import java.util.Scanner;
2+
3+
public class Main {
4+
public static void main(String[] args) {
5+
Scanner sc= new Scanner(System.in);
6+
long N= sc.nextLong();
7+
long sum=0;
8+
long guide =10;
9+
long len=1;
10+
for (long i = 1; i <= N; i++) {
11+
if(i==guide){
12+
guide*=10;
13+
len+=1;
14+
}
15+
sum+=len;
16+
}
17+
System.out.println(sum);
18+
19+
}
20+
}

BOJ/silver/BOj14501/BOj14501.iml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module type="JAVA_MODULE" version="4">
3+
<component name="NewModuleRootManager" inherit-compiler-output="true">
4+
<exclude-output />
5+
<content url="file://$MODULE_DIR$">
6+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
7+
</content>
8+
<orderEntry type="inheritedJdk" />
9+
<orderEntry type="sourceFolder" forTests="false" />
10+
</component>
11+
</module>

BOJ/silver/BOj14501/src/Main.java

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import java.io.BufferedReader;
2+
import java.io.IOException;
3+
import java.io.InputStreamReader;
4+
5+
6+
public class Main {
7+
public static void main(String[] args) throws IOException {
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
10+
11+
int N = Integer.parseInt(br.readLine());
12+
int [] dp =new int [N+2];
13+
int [] T = new int [N+1];
14+
int [] P =new int [N+1];
15+
16+
for (int i = 0; i < N; i++) {
17+
String [] tmp= br.readLine().split(" ");
18+
int t = Integer.parseInt(tmp[0]);
19+
int p = Integer.parseInt(tmp[1]);
20+
21+
if(t+i<=N+1){
22+
dp[i+t]=Math.max(dp[i]+p, dp[i+t]);
23+
}
24+
dp[i+1]=Math.max(dp[i+1],dp[i]);
25+
26+
}
27+
System.out.println(dp[N]);
28+
29+
}
30+
}

0 commit comments

Comments
 (0)