結果

問題 No.587 七対子
ユーザー rymg111rymg111
提出日時 2020-09-22 22:36:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 4,737 ms
コンパイル使用メモリ 73,172 KB
実行使用メモリ 56,208 KB
最終ジャッジ日時 2023-09-27 02:57:52
合計ジャッジ時間 9,541 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,928 KB
testcase_01 AC 125 ms
56,004 KB
testcase_02 AC 122 ms
55,788 KB
testcase_03 AC 122 ms
56,208 KB
testcase_04 AC 121 ms
55,508 KB
testcase_05 AC 120 ms
55,564 KB
testcase_06 AC 120 ms
55,656 KB
testcase_07 AC 121 ms
56,148 KB
testcase_08 AC 120 ms
55,400 KB
testcase_09 AC 121 ms
55,616 KB
testcase_10 AC 121 ms
55,364 KB
testcase_11 AC 125 ms
55,912 KB
testcase_12 AC 121 ms
55,688 KB
testcase_13 AC 122 ms
55,360 KB
testcase_14 AC 121 ms
55,664 KB
testcase_15 AC 121 ms
55,904 KB
testcase_16 AC 125 ms
55,724 KB
testcase_17 AC 123 ms
55,800 KB
testcase_18 AC 125 ms
56,016 KB
testcase_19 AC 121 ms
56,040 KB
testcase_20 AC 122 ms
55,768 KB
testcase_21 AC 122 ms
55,860 KB
testcase_22 AC 120 ms
55,680 KB
testcase_23 AC 124 ms
55,760 KB
testcase_24 AC 121 ms
55,608 KB
testcase_25 AC 120 ms
55,716 KB
testcase_26 AC 131 ms
55,600 KB
testcase_27 AC 132 ms
55,464 KB
testcase_28 AC 121 ms
55,340 KB
testcase_29 AC 123 ms
55,512 KB
testcase_30 AC 124 ms
55,712 KB
testcase_31 AC 121 ms
55,344 KB
testcase_32 AC 121 ms
55,920 KB
testcase_33 AC 127 ms
55,364 KB
testcase_34 AC 121 ms
55,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

// No.587 七対子
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String haipai = sc.next();
		StringBuilder machi = new StringBuilder();
		for(int i = 0; i < 13; i++) {
			String pai = haipai.substring(i, i + 1);
			if(count(pai, haipai) == 2) {
				continue;
			} else if(count(pai, haipai) == 1) {
				machi.append(pai);
				if(machi.length() != 1) {
					machi = new StringBuilder("Impossible");
					break;
				}
			} else {
				machi = new StringBuilder("Impossible");
				break;
			}
		}
		System.out.println(machi);
	}
	public static int count(String pai, String haipai) {
		int index = 0;
		int count = 0;
		while(true) {
			index = haipai.indexOf(pai, index) + 1;
			if(index == 0) {
				break;
			}
			count++;
		}
		return count;
	}
}
0