結果

問題 No.964 2020
ユーザー mmn15277198mmn15277198
提出日時 2020-02-24 18:50:28
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,020 ms
コード長 1,056 bytes
コンパイル時間 592 ms
コンパイル使用メモリ 65,040 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-20 12:58:02
合計ジャッジ時間 1,240 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
using namespace std;
 
int check(int arr[] , int arr_size){
	
	int i,j;
	i=0;
	j=0;
	
	while(i < arr_size){
		if(arr[i] == 0){
			j++;
		}
		i++;
	}
	
		//cout << "return" << endl;
	return j;
}

int main(void){
    int a,b,c,d,e,i,j,p[10],q[10];
    
    cin >> a;
    if(a<1 || 10<a) exit(1);  
    
    i=0;
    j=1;
    p[0]=rand()%10;
    p[1]=rand()%10;
    
	while(j<a){
			//cout << "i,j=" << i << "," << j << ">>>";
			//cout << "p[i],p[j]=" << p[i] << "," << p[j] << endl;
			
			if(p[i] != p[j]){
				i++;
			}else{
				i=0;
				j=1;
				//p[j]=rand()%10;
			}
			if(i==j){
				i=0;
				j++;
				p[j]=rand()%10;
			}
	}
	i=0;
	j=0;
	
	while(i<a){
		q[i]=a;
		//cout << "p[i],q[i]=" << p[i] << "," << q[i] << endl;
		//cout << "p[i]=" << p[i] << endl;
		i++;
	}
	i=0;
	c=0;
	while(1){
		if(check(q,a) == a)break;
		//cout << "check_2" << endl;
		
		b=rand()%a;
		
			while(c == 0){
				if( p[b] != 0){
					c=1;
					break;
				}
				b=rand()%a;
			}

		if(q[b] != 0){
			cout << p[b];
			q[b] -= 1;
		}
	}
			
    return 0;
}
0