Last active
May 14, 2018 23:51
-
-
Save hiramekun/3556ced882e4ef4edf6d8ce901638d4e to your computer and use it in GitHub Desktop.
AtCoder Beginner Contest 097
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
import java.util.Scanner; | |
class ColorfulTransceivers { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int a = scanner.nextInt(); | |
int b = scanner.nextInt(); | |
int c = scanner.nextInt(); | |
int d = scanner.nextInt(); | |
if (Math.abs(a - c) <= d){ | |
System.out.print("Yes"); | |
} else if (Math.abs(a-b) <=d && Math.abs(b-c) <= d) { | |
System.out.print("Yes"); | |
} else{ | |
System.out.print("No"); | |
} | |
} | |
} |
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
import java.util.Scanner; | |
class Exponential { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
int X = scanner.nextInt(); | |
int max = 1; | |
for (int x = X / 2; x > 1; x--) { | |
for (int y = X / 2; y > 1; y--) { | |
double pow = Math.pow((double) x, (double) (y)); | |
if (pow > max && pow < X) { | |
max = ((int) pow); | |
} | |
} | |
} | |
System.out.print(max); | |
} | |
} |
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
import java.util.ArrayList; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Scanner; | |
class KthSubstring { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
String s = scanner.nextLine(); | |
int K = scanner.nextInt(); | |
List<String> strings = new ArrayList<>(); | |
for (int i = 0; i < s.length(); i++) { | |
for (int j = 1; j < 6; j++) { | |
if (i + j > s.length()) { | |
break; | |
} | |
String sub = s.substring(i, i + j); | |
if (!strings.contains(sub)){ | |
strings.add(sub); | |
} | |
} | |
} | |
// sort | |
Collections.sort(strings); | |
System.out.print(strings.get(K - 1)); | |
} | |
} |
Author
hiramekun
commented
May 13, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment