結果
問題 | No.587 七対子 |
ユーザー |
|
提出日時 | 2020-09-22 22:36:48 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 117 ms / 2,000 ms |
コード長 | 831 bytes |
コンパイル時間 | 3,245 ms |
コンパイル使用メモリ | 74,148 KB |
実行使用メモリ | 41,340 KB |
最終ジャッジ日時 | 2024-07-19 20:23:31 |
合計ジャッジ時間 | 7,720 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 35 |
ソースコード
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; } }