結果

問題 No.587 七対子
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-10 23:02:33
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 2,000 ms
コード長 815 bytes
コンパイル時間 2,279 ms
コンパイル使用メモリ 71,332 KB
実行使用メモリ 55,776 KB
最終ジャッジ日時 2023-09-27 02:19:39
合計ジャッジ時間 7,925 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 118 ms
55,600 KB
testcase_01 AC 121 ms
55,728 KB
testcase_02 AC 119 ms
55,652 KB
testcase_03 AC 118 ms
55,432 KB
testcase_04 AC 118 ms
55,388 KB
testcase_05 AC 115 ms
55,212 KB
testcase_06 AC 118 ms
55,600 KB
testcase_07 AC 117 ms
55,200 KB
testcase_08 AC 120 ms
55,764 KB
testcase_09 AC 124 ms
55,192 KB
testcase_10 AC 123 ms
55,420 KB
testcase_11 AC 121 ms
55,696 KB
testcase_12 AC 119 ms
55,716 KB
testcase_13 AC 119 ms
53,340 KB
testcase_14 AC 117 ms
55,476 KB
testcase_15 AC 119 ms
55,532 KB
testcase_16 AC 118 ms
55,556 KB
testcase_17 AC 118 ms
55,376 KB
testcase_18 AC 118 ms
55,604 KB
testcase_19 AC 117 ms
55,728 KB
testcase_20 AC 122 ms
55,708 KB
testcase_21 AC 119 ms
55,756 KB
testcase_22 AC 118 ms
55,652 KB
testcase_23 AC 117 ms
55,776 KB
testcase_24 AC 118 ms
55,512 KB
testcase_25 AC 117 ms
55,592 KB
testcase_26 AC 116 ms
55,500 KB
testcase_27 AC 116 ms
55,232 KB
testcase_28 AC 123 ms
55,504 KB
testcase_29 AC 120 ms
53,764 KB
testcase_30 AC 120 ms
55,408 KB
testcase_31 AC 119 ms
55,464 KB
testcase_32 AC 118 ms
55,576 KB
testcase_33 AC 118 ms
55,176 KB
testcase_34 AC 119 ms
53,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int[] alphabet = new int[26];
		String s = sc.next();
		for (int i=0; i<s.length(); i++) {
			char c = s.charAt(i);
			alphabet[c-97]++;
		}
		
		//ループで配列alphabetの要素を調べる。
		//2が6個、1が1個の場合、成り立つので、1が入ってる番号をアルファベットにして出力。
		//それ以外のパターンの場合、impossibleを出力。
		
		int two = 0;
		int one = 0;
		int one_num = 0;
		
		for (int i=0; i<alphabet.length; i++) {
			if (alphabet[i]==2) {two++;}
			else if (alphabet[i]==1) {one++; one_num = i;}
		}
		
		if (two==6 && one==1) {System.out.println((char)(one_num+97));}
		else {System.out.println("Impossible");}
	}
}
0