結果

問題 No.587 七対子
ユーザー YamaKasa
提出日時 2018-06-06 21:29:13
言語 Java
(openjdk 23)
結果
AC  
実行時間 118 ms / 2,000 ms
コード長 612 bytes
コンパイル時間 2,147 ms
コンパイル使用メモリ 75,140 KB
実行使用メモリ 41,192 KB
最終ジャッジ日時 2024-07-19 19:53:50
合計ジャッジ時間 6,340 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

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