(体会不同的编程思想的效率差异)A and B and Compilation Errors (看完题先思考如何解决更好)
来源:互联网 发布:大数据是一种思维方式 编辑:程序博客网 时间:2024/05/17 05:58
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?
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.
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.
51 5 8 123 7123 7 5 15 1 7
8123
61 4 3 3 5 73 7 5 4 34 3 7 5
13
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.
#include<iostream>using namespace std;int main(){int n;while(cin>>n){int i;int sum_1=0,sum_2=0;int T;for(i=0;i<n;i++){cin>>T;sum_1+=T;}int j;int n1=n-1;for(j=0;j<2;j++){for(i=0;i<n1;i++){cin>>T;sum_2+=T;}cout<<sum_1-sum_2<<endl;sum_1=sum_2;sum_2=0;n1--;}}return 0;}直接用和减和,比一个数一个数的比较效率高太多了,用一个数一个数比较的方法会超秒。
- (体会不同的编程思想的效率差异)A and B and Compilation Errors (看完题先思考如何解决更好)
- B. A and B and Compilation Errors
- B - A and B and Compilation Errors
- A and B and Compilation Errors——找出消失的数字
- 519B. A and B and Compilation Errors【implamentation】
- coderforce B .A and B and Compilation Errors
- A and B and Compilation Errors 519B
- Codeforces Round #294 (Div. 2) -- B. A and B and Compilation Errors
- codeforces——519B—— A and B and Compilation Errors
- chapter 8 Compilation, Execution, and Errors
- 一个简单的集合并级取反问题 !A or !B == !(A and B)
- A and B and Interesting Substrings(学习利用map容器提高效率的技巧)
- A and B and Team Training(贪心思想)
- LUA学习笔记3 - Compilation, Execution, and Errors
- LUA学习笔记3 - Compilation, Execution, and Errors
- LUA学习笔记之 Compilation, Execution, and Errors
- CF:374A - Inna and Pink Pony(思想题)
- HTML编码建议And如何更好的编码
- JNI开发之JNI实践
- Shell脚本基础1-先清楚几个概念
- 计蒜客 灌溉 (最小生成树之prim算法)
- Hibernate 的三种查询方式:HQL、Criteria、Sql
- centos安装redis——(架构篇)
- (体会不同的编程思想的效率差异)A and B and Compilation Errors (看完题先思考如何解决更好)
- webpack+gulp实现自动构建部署
- 格式化输出
- HTML跳转php没反应的问题解决
- c++控制台贪吃蛇(类实现)
- 路由选择基础
- Java和C++在函数参数传递上的不同
- 滚动图
- 注意头文件规则,避免链接错误:重定义(multiple defination)