U E D R , A S I H C RSS

1R/2016_07_04


1. 오늘의 문제

2. 참가자

이름 학번
박인서 15학번
15이원준 15학번

3. 코드

3.1. 박인서

#include <cstdio>

int main(int argc, char** argv) {
	setbuf(stdout, NULL);
	int TC;
	int test_case;
    
	scanf("%d", &TC);
	for(test_case = 1; test_case <= TC; test_case++) {
	    int n, x=0;
	    scanf("%d",&n);
	    
	    for(int i=0;i<n;i++){
	        int t;
	        scanf("%d",&t);
	        x=x^t;
	    }
	    
        printf("Case #%d\n", test_case);
        printf("%d\n", x);
	}
	return 0;
}

3.2. 이원준

#include <stdio.h>

int main(void) {
	
	setbuf(stdout, NULL);

	int TC;
	int test_case;

	scanf("%d", &TC);
	for (test_case = 1; test_case <= TC; test_case++) {
		int n;
		int temp;
		int ans = 0;
		scanf("%d", &n);
		for (int i = 0; i < n; i++){
			scanf("%d", &temp);
			ans ^= temp;
		}
	printf("Case #%d\n", test_case);
		printf("%d\n", ans);

	}

	return 0;
}

4. 아이디어

4.1. 박인서

  • 같은 수를 짝수 번 XOR하면 0이 된다는 아이디어를 이용

4.2. 15이원준

  • 위와 같습니다.
  • 그보다 main parameter에 void해도 통과되더군요 :)
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:06
Processing time 0.0200 sec