結果

問題 No.355 数当てゲーム(2)
ユーザー 37zigen
提出日時 2016-04-02 13:40:58
言語 Java
(openjdk 23)
結果
AC  
実行時間 206 ms / 2,000 ms
コード長 1,209 bytes
コンパイル時間 2,167 ms
コンパイル使用メモリ 79,300 KB
実行使用メモリ 73,540 KB
平均クエリ数 27.13
最終ジャッジ日時 2024-07-16 23:25:24
合計ジャッジ時間 14,451 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder355;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int[] d={0,1,2,3};
		for(int i=0;i<4;i++){;
		boolean flag=false;
		int memo=0;
		int flagValue=-1;
			for(int j=0;j<10;j++){
				d[i]=j;
				boolean f=true;
				//重複する数字がある組み合わせを除去
				for(int k=0;k<4;k++){
					if(d[i]==d[k]&&i!=k)f=false;
				}
				if(!f)continue;
				System.out.println(d[0]+" "+d[1]+" "+d[2]+" "+d[3]);
				int aa=sc.nextInt();
				int bb=sc.nextInt();
				if(aa==4&bb==0){
					return;
				}else if(!flag){
					memo=aa+bb;
					flagValue=j;
					flag=true;
				}else if(flag){
					if(memo<aa+bb){
						break;
					}else if(memo==aa+bb){
						continue;
					}else if(memo>aa+bb){
						d[i]=flagValue;
						break;
					}
				}
			}
			
			
		}

		for(int i=0;i<4;i++){
			for(int j=0;j<4;j++){
				if(i==j)continue;
				for(int k=0;k<4;k++){
					if(i==k||j==k)continue;
					for(int l=0;l<4;l++){
						if(i==l||j==l||k==l)continue;
						System.out.println(d[i]+" "+d[j]+" "+d[k]+" "+d[l]);
						int a=sc.nextInt();
						int b=sc.nextInt();
						if(a==4&&b==0)return;
					}
				}
			}
		}
	}
}
0