HZAU 1007 Find The Difference

原题

#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
using namespace std;
const int MAX_N = 100000 + 9;
void solve()
{
  int n;
  scanf("%d", &n);
  int a[MAX_N];
  memset(a, 0, sizeof(a));
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  set<int> myset;
  for (int i = 0; i < n - 1; i++) {
    int x;
    scanf("%d", &x);
    myset.insert(x);
  }
  int ans;
  for (int i = 0; i < n; i++) {
    if (myset.count(a[i]) == 0) {
      ans = a[i];
      break;
    }
  }
  printf("%d\n", ans);
}
int main()
{
// freopen("input.txt", "r", stdin);
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    solve();
  }
}

你可能感兴趣的:(HZAU 1007 Find The Difference)