結果

問題 No.183 たのしい排他的論理和(EASY)
ユーザー akakimidori
提出日時 2015-07-26 19:25:58
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 205 ms / 5,000 ms
コード長 625 bytes
コンパイル時間 852 ms
コンパイル使用メモリ 20,992 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-29 02:33:39
合計ジャッジ時間 2,478 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:12:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d",&N);
      |         ^~~~~~~~~~~~~~
main.c:18:26: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   18 |         for(i=0;i<N;i++) scanf("%d\n",&A[i]);
      |                          ^~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

#define ABS(x) ((x)>0?(x):-(x))
#define MAX(a,b) ((a)>(b)?(a):(b))

typedef long long int ln;

int main(void){

	int N;
	scanf("%d",&N);

	int *A;
	A=(int *)malloc(sizeof(int)*N);

	int i;
	for(i=0;i<N;i++) scanf("%d\n",&A[i]);

	int UP=1<<15;
	char *can;
	can=(char *)malloc(sizeof(char)*UP);

	for(i=0;i<UP;i++) can[i]=0;

	can[0]=1;
	int max=0;
	for(i=0;i<N;i++){
		int j;
		for(j=0;j<=max;j++){
			if(can[j]){
				int t=j^A[i];
				can[t]=1;
				max=MAX(max,t);
			}
		}
	}

	int count=0;
	for(i=0;i<=max;i++) count+=can[i];
	printf("%d\n",count);
	free(A);
	free(can);
	return 0;
}
0