-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.StringTokenizer; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
|
||
static class Coordinate{ | ||
int x; | ||
int y; | ||
|
||
public Coordinate(int x, int y) { | ||
this.y = y; | ||
this.x = x; | ||
} | ||
|
||
private int minDifference(Coordinate c){ | ||
return Math.min( | ||
Math.abs(this.x - c.x), | ||
Math.abs(this.y - c.y) | ||
); | ||
} | ||
} | ||
|
||
public static void main(String[] args) throws IOException { | ||
StringTokenizer st = new StringTokenizer(br.readLine()); | ||
Coordinate hansu = new Coordinate( | ||
Integer.parseInt(st.nextToken()), | ||
Integer.parseInt(st.nextToken()) | ||
); | ||
|
||
Coordinate lowerLeft = new Coordinate(0 ,0); | ||
|
||
Coordinate upperRight = new Coordinate( | ||
Integer.parseInt(st.nextToken()), | ||
Integer.parseInt(st.nextToken()) | ||
); | ||
|
||
int min = Integer.MAX_VALUE; | ||
|
||
min = Math.min(min, hansu.minDifference(lowerLeft)); | ||
min = Math.min(min, hansu.minDifference(upperRight)); | ||
|
||
System.out.println(min); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
import java.util.Arrays; | ||
import java.util.Comparator; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
static StringBuilder sb = new StringBuilder(); | ||
|
||
public static void main(String[] args) throws IOException { | ||
int n = Integer.parseInt(br.readLine()); | ||
String[] strs = new String[n]; | ||
Set<String> visited = new HashSet<>(); | ||
|
||
for (int i = 0; i < n; i++) { | ||
strs[i] = br.readLine(); | ||
} | ||
|
||
Arrays.sort(strs, | ||
new Comparator<String>() { | ||
@Override | ||
public int compare(String o1, String o2) { | ||
if(o1.length() == o2.length()) | ||
return o1.compareTo(o2); | ||
else { | ||
return o1.length() - o2.length(); | ||
} | ||
} | ||
}); | ||
|
||
System.out.println( | ||
Arrays.stream(strs) | ||
.filter(s -> { | ||
if(!visited.contains(s)){ | ||
visited.add(s); | ||
return true; | ||
} | ||
return false; | ||
}) | ||
.map(String::valueOf) | ||
.collect(Collectors.joining("\n")) | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
static StringBuilder sb = new StringBuilder(); | ||
|
||
public static void main(String[] args) throws IOException { | ||
while (true){ | ||
int n = Integer.parseInt(br.readLine()); | ||
if(n == 0) break; | ||
char[] ary = String.valueOf(n).toCharArray(); | ||
sb.append(getAnswer(ary)).append("\n"); | ||
} | ||
System.out.println(sb.toString()); | ||
} | ||
|
||
private static String getAnswer(char[] ary) { | ||
int left = 0, right = ary.length - 1; | ||
|
||
while (left < right){ | ||
if(ary[left++] != ary[right--]) return "no"; | ||
} | ||
return "yes"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
public class Main { | ||
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | ||
static StringBuilder sb = new StringBuilder(); | ||
|
||
public static void main(String[] args) throws IOException { | ||
int turn = Integer.parseInt(br.readLine()); | ||
long n = 666; | ||
|
||
int cnt = 0; | ||
while (true){ | ||
char[] numArray = String.valueOf(n).toCharArray(); | ||
if(isValid(numArray)) cnt++; | ||
if(cnt == turn) break; | ||
n++; | ||
} | ||
System.out.println(n); | ||
} | ||
|
||
private static boolean isValid(char[] numArray) { | ||
for (int i = 0; i <= numArray.length - 3; i++) { | ||
if(numArray[i] == '6' && numArray[i + 1] == '6' && numArray[i + 2] == '6'){ | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |