結果
| 問題 |
No.293 4>7の世界
|
| コンテスト | |
| ユーザー |
tom_tom_tom
|
| 提出日時 | 2015-11-11 08:12:52 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 4,070 bytes |
| コンパイル時間 | 4,092 ms |
| コンパイル使用メモリ | 84,688 KB |
| 実行使用メモリ | 54,348 KB |
| 最終ジャッジ日時 | 2024-09-13 14:23:38 |
| 合計ジャッジ時間 | 8,203 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 17 WA * 3 |
ソースコード
package me.yukicoder;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import static java.util.stream.Collectors.joining;
import static java.util.stream.Collectors.toList;
public class YukiCoder293 {
private static boolean LOCAL = System.getenv().keySet().stream().anyMatch(key -> key.startsWith("JAVA_MAIN_CLASS"));
public static void run() {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
String[] org = s.split(" ");
String l = org[0];
String r = org[1];
s = s.replace('4', 'A');
s = s.replace('7', '4');
s = s.replace('A', '7');
String[] ss = s.split(" ");
long a = Long.parseLong(ss[0]);
long b = Long.parseLong(ss[1]);
boolean left = false;
if (a > b) {
left = true;
}
System.out.println(left ? l : r);
}
private static TestCase getTest1() {
return new TestCase("4", "4 7");
}
private static TestCase getTest2() {
return new TestCase("5", "5 7");
}
private static TestCase getTest3() {
return new TestCase("170", "40 170");
}
private static TestCase getTest4() {
return new TestCase("1234567890", "1237564890 1234567890");
}
private static TestCase getTest5() {
return new TestCase("", "");
}
public static void main(String[] args) {
perform();
}
private static void perform() {
if (LOCAL) {
List<TestCase> tests = getTests();
boolean passed = true;
int index = 1;
for (TestCase testCase : getTests()) {
String input = Arrays.stream(testCase.inputs).collect(joining(System.lineSeparator()));
InputStream in = new ByteArrayInputStream(input.getBytes());
System.setIn(in);
PrintStream sout = System.out;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
System.setOut(ps);
try {
run();
} finally {
System.setOut(sout);
}
System.out.flush();
String actual = baos.toString().trim();
String expect = testCase.expect;
boolean match = expect != null && expect.equals(actual);
System.out.println("------------------------ " + index++ + "/" + tests.size() + " " + (match ? "PASS" : "FAIL"));
System.out.println("INPUT: " + input);
System.out.println("RESULT: " + match);
System.out.println("EXPECTED: " + expect + ":");
System.out.println("ACTUAL: " + actual + ":");
if (!match) passed = false;
}
System.out.println("\n==== SUMMARY ==== ");
System.out.println(passed ? "PASS" : "FAIL");
} else {
run();
}
}
public static List<TestCase> getTests() {
List<TestCase> testCases = new ArrayList<>();
testCases.add(getTest1());
testCases.add(getTest2());
testCases.add(getTest3());
testCases.add(getTest4());
testCases.add(getTest5());
return testCases.stream().filter(t -> !t.ignore()).collect(toList());
}
private static class TestCase {
String expect;
String[] inputs;
public TestCase(String expect, String[] inputs) {
this.expect = expect;
this.inputs = inputs;
}
public TestCase(String expect, String input) {
this.expect = expect;
this.inputs = new String[]{input};
}
public boolean ignore() {
return "".equals(expect) && inputs.length == 1 && "".equals(inputs[0]);
}
}
}
tom_tom_tom