zoukankan      html  css  js  c++  java
  • CodeForces 519B A and B and Compilation Errors

    B. A and B and Compilation Errors
    time limit per test
    2 seconds
    memory limit per test
    256 megabytes
    input
    standard input
    output
    standard output

    A and B are preparing themselves for programming contests.

    B loves to debug his code. But before he runs the solution and starts debugging, he has to first compile the code.

    Initially, the compiler displayed n compilation errors, each of them is represented as a positive integer. After some effort, B managed to fix some mistake and then another one mistake.

    However, despite the fact that B is sure that he corrected the two errors, he can not understand exactly what compilation errors disappeared — the compiler of the language which B uses shows errors in the new order every time! B is sure that unlike many other programming languages, compilation errors for his programming language do not depend on each other, that is, if you correct one error, the set of other error does not change.

    Can you help B find out exactly what two errors he corrected?

    Input

    The first line of the input contains integer n (3 ≤ n ≤ 105) — the initial number of compilation errors.

    The second line contains n space-separated integers a1, a2, ..., an (1 ≤ ai ≤ 109) — the errors the compiler displayed for the first time.

    The third line contains n - 1 space-separated integers b1, b2, ..., bn - 1 — the errors displayed at the second compilation. It is guaranteed that the sequence in the third line contains all numbers of the second string except for exactly one.

    The fourth line contains n - 2 space-separated integers с1, с2, ..., сn - 2 — the errors displayed at the third compilation. It is guaranteed that the sequence in the fourth line contains all numbers of the third line except for exactly one.

    Output

    Print two numbers on a single line: the numbers of the compilation errors that disappeared after B made the first and the second correction, respectively.

    Sample test(s)
    Input
    5
    1 5 8 123 7
    123 7 5 1
    5 1 7
    Output
    8
    123
    Input
    6
    1 4 3 3 5 7
    3 7 5 4 3
    4 3 7 5
    Output
    1
    3
    Note

    In the first test sample B first corrects the error number 8, then the error number 123.

    In the second test sample B first corrects the error number 1, then the error number 3. Note that if there are multiple errors with the same number, B can correct only one of them in one step.

    这道题目其实在上周周日就做过,今天刚好又碰到了,就拿巧办法写了一下。

    周日写的时候,使用排序,扫描的方法写的,也容易想。这个办法是JS说的,给每组求个和,一减下一组的和,就是答案。

     1 #include <iostream>
     2 #include <cstdio>
     3 #include <cstring>
     4 #include <algorithm>
     5 using namespace std;
     6 
     7 int main()
     8 {
     9     int n, read;
    10     int sum1, sum2, sum3;
    11     sum1 = sum2 = sum3 = 0;
    12     scanf("%d", &n);
    13     for(int i = 0; i < n; i++)
    14     {
    15         scanf("%d", &read);
    16         sum1 += read;
    17     }
    18 
    19     for(int i = 0; i < n-1; i++)
    20     {
    21         scanf("%d", &read);
    22         sum2 += read;
    23     }
    24     cout << sum1 - sum2 << endl;
    25 
    26     for(int i = 0; i < n-2; i++)
    27     {
    28         scanf("%d", &read);
    29         sum3 += read;
    30     }
    31 
    32     cout << sum2 - sum3 << endl;
    33     return 0;
    34 }
    View Code
  • 相关阅读:
    FreeSql (二十)多表查询 WhereCascade
    FreeSql (十九)多表查询
    FreeSql (十八)导航属性
    FreeSql (十七)联表查询
    FreeSql (十六)分页查询
    C#实现.Net对邮件进行DKIM签名和验证,支持附件,发送邮件签名后直接投递到对方服务器(无需己方邮件服务器)
    C#的RSA加密解密签名,就为了支持PEM PKCS#8格式密钥对的导入导出
    Zookeeper Windows版的服务安装和管理工具
    Nginx Windows版的服务安装和管理工具
    1kb的前端HTML模板解析引擎,不限于嵌套、循环、函数你能想到的解析方式
  • 原文地址:https://www.cnblogs.com/ya-cpp/p/4348750.html
Copyright © 2011-2022 走看看