結果

問題 No.587 七対子
ユーザー YamaKasaYamaKasa
提出日時 2018-06-06 21:29:13
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 2,334 ms
コンパイル使用メモリ 72,452 KB
実行使用メモリ 56,328 KB
最終ジャッジ日時 2023-09-27 02:23:42
合計ジャッジ時間 7,750 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
55,928 KB
testcase_01 AC 121 ms
55,964 KB
testcase_02 AC 124 ms
55,792 KB
testcase_03 AC 123 ms
55,856 KB
testcase_04 AC 121 ms
55,740 KB
testcase_05 AC 122 ms
55,848 KB
testcase_06 AC 124 ms
53,536 KB
testcase_07 AC 121 ms
55,920 KB
testcase_08 AC 123 ms
55,664 KB
testcase_09 AC 121 ms
55,656 KB
testcase_10 AC 120 ms
55,756 KB
testcase_11 AC 119 ms
55,664 KB
testcase_12 AC 120 ms
55,528 KB
testcase_13 AC 121 ms
55,564 KB
testcase_14 AC 122 ms
56,328 KB
testcase_15 AC 124 ms
55,496 KB
testcase_16 AC 124 ms
55,700 KB
testcase_17 AC 123 ms
55,756 KB
testcase_18 AC 122 ms
55,904 KB
testcase_19 AC 123 ms
55,556 KB
testcase_20 AC 123 ms
55,472 KB
testcase_21 AC 123 ms
55,848 KB
testcase_22 AC 124 ms
55,572 KB
testcase_23 AC 123 ms
55,664 KB
testcase_24 AC 122 ms
55,728 KB
testcase_25 AC 122 ms
55,764 KB
testcase_26 AC 124 ms
55,480 KB
testcase_27 AC 123 ms
55,660 KB
testcase_28 AC 123 ms
55,896 KB
testcase_29 AC 122 ms
55,476 KB
testcase_30 AC 121 ms
55,568 KB
testcase_31 AC 122 ms
55,656 KB
testcase_32 AC 121 ms
55,908 KB
testcase_33 AC 122 ms
55,624 KB
testcase_34 AC 123 ms
55,728 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		scan.close();
		String []ary = s.split("");
		int l = ary.length;
		int cnt1 = 0;
		int cnt2 = 0;
		String a = "";
		for(int i = 0; i < l; i++) {
			String t = ary[i];
			for(int j = 0; j < l; j++) {
				if(t.equals(ary[j])) {
					cnt1 ++;
				}
			}
			if(cnt1 == 1) {
				a = t;
				cnt2 ++;
			}else if(cnt1 >= 3) {
				cnt2 ++;
			}
			cnt1 = 0;
		}
		if(cnt2 == 1) {
			System.out.println(a);
		}else {
			System.out.println("Impossible");
		}
	}
}
0