也就是今天小测的ProblemA。
传送门:http://acm.hit.edu.cn/hojx/showproblem/3181/
3181 - Sign in
Time limit : 3 s Memory limit : 32 mb
Submitted : 312 Accepted : 96
Submit
Problem Description
As we all know that, in an ACM contest, there is always an easy problem which every team can
AC it easily. We usually call this kind of problem, “the sign-in problem”.
But after the contest, we find that there is one team didn’t come to participate in the
contest, now please help me to find which team it is.
Input
The first line contains an integer T, meaning the number of the cases.
For each test case:
The first line is a number N (1 <= N <= 10^5) showing that N teams had registered for the contest. In the next line there are N distinct numbers, the team number of N teams. (The team number is an integer more than 0 and less than 10^8). The last line are N-1 distinct numbers, the team number of N-1 teams who AC the problem.
Output
“Team XXXXXXXX didn’t sign in!” (XXXXXXXX is the team number and should be 8 digits, using 0s to fill in if the number isn’t 8 digits).
Sample Input
2
2
10 30
10
3
1 2 3
1 3
Sample Output
Team 00000030 didn’t sign in!
Team 00000002 didn’t sign in!
嗯,学长说这是签到题,无论是从题面和难易程度上看都是如此。
刚开始写的时候很脑残地在想怎么循环判断用0把位数占满。。。还因为最后一个没判断WA了一次。。。
后来发现直接用%08d就好了。。。
AC代码如下:
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define maxn 100005
int a[maxn];
int b[maxn];
int main()
{
int kase;
scanf("%d", &kase);
while(kase--)
{
int n;
scanf("%d", &n);
for(int i = 0; i < n; i++)
scanf("%d", &a[i]);
for(int i = 0; i < n-1; i++)
scanf("%d", &b[i]);
sort(a, a+n);
sort(b, b+n-1);
for(int i = 0; i < n; i++)
{
if(a[i] != b[i] || i == n-1)
{
printf("Team %08d didn't sign in!\n", a[i]);
break;
}
}
}
return 0;
}