0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paizaレベルアップ問題集「Sランクレベルアップメニュー」をやってみた~XOR

0
Last updated at Posted at 2026-11-30

paizaレベルアップ問題集「Sランクレベルアップメニュー」の「XOR」をやってみました。


問題


方針
  • 数列の長さを表す整数$N$を受け取ります
  • 数列$A_1,A_2,\dots,A_n$を受け取ります
  • $X=0$で初期化します
  • $i=1,2,\dots,N$に対して
    • $X=X\oplus A_i$で更新します
  • $X$を出力します

実装例
#include <stdio.h>

int main(void) {
	size_t N;
	scanf("%zu", &N);
	unsigned A[N];
	for (size_t i = 0; i < N; i++) {
		scanf("%u", &A[i]);
	}
	unsigned xor = 0;
	for (size_t i = 0; i < N; i++) {
		xor ^= A[i];
	}
	printf("%u\n", xor);
	return 0;
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?