HOJ 3181 - Sign in(签到题)

也就是今天小测的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;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值