Problem G: Find The Difference

Problem G: Find The Difference

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 214  Solved: 161
[ Submit][ Status][ Web Board]

Description

    Diao Fei is very good at the game which names “Find the difference”. The game’s rule is giving two pictures and you should find all the differences between these two pictures.

    Diao Ze is very good at math, and he thinks finding the differences in pictures is very boring, he giving a similar problem to Diao Fei: Giving you two number sequences, can you find the differences between these two number sequences?

To simplify the problem, the two number sequences satisfied:

·In each sequence, all the numbers are distinct.

·The first sequence has exactly one more number than the second sequence and there is only one number which is in the first sequence but not in the second sequence.

    Your task is to help Diao Fei find the number which is in the first sequence but not in the second sequence.

Input

    The first line contains an integer T, indicating the total number of test cases.

    For each test case, there are three lines. The first line contains an integer n(), indicating the first sequence has  numbers and the second sequences has n-1 numbers. Then the second line contains n integers which in the first sequence and the third line contains n-1 integers which in the second sequence. Each integer in each sequence is less than 231.

Output

    For each test case, output the answer in one line.

Sample Input

231 2 31 2534 421 97 456 19238421 19238 97 34

Sample Output

3456

HINT



#include<stdio.h>
#include<string.h>
int inf=9999999;
int main()
{
	int a[100005];
	int b[100005];
	int T,i,j;
	scanf("%d",&T);
	while(T--)
	{
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		int n;
		scanf("%d",&n);
		for(i=1;i<=n;i++)
			scanf("%d",&a[i]);
		for(i=1;i<n;i++)
			scanf("%d",&b[i]);
		for(i=1;i<=n;i++)
		{
			for(j=1;j<=n-1;j++)
			{
				if(a[i]==b[j])
					break;;
			}
			if(j==n)
			{
				printf("%d\n",a[i]);
				break;
			}
		}
	}
	return 0;
}







评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值