题记:一个水题,在打比赛的时候太过于紧张,着急想出题,所以就没读懂题意就开始做,导致了错了四次,后来还听说可以有中文翻译,真是垂头顿足。以后做题应该先整理好思路再做题。
关于这个题目:题目为找数问题,从1开始,若没有就输出,直到输出两个结束例如如果输入是6,7,8的时候,就输出1 2
Missing number
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 748 Accepted Submission(s): 275
Problem Description
There is a permutation without two numbers in it, and now you know what numbers the permutation has. Please find the two numbers it lose.
Input
There is a number T shows there are T test cases below. ( T≤10 ) For each test case , the first line contains a integers n , which means the number of numbers the permutation has. In following a line , there are n distinct postive integers.( 1≤n≤1,000 )
Output
For each case output two numbers , small number first.
Sample Input
2 3 3 4 5 1 1
Sample Output
1 2 2 3#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; int main() { int a,b,c[1011],s[1011]; int i; while(~scanf("%d",&a)) { while(a--) { memset(c,0,sizeof(c)); int sum=0; scanf("%d",&b); for(i=0;i<b;i++) scanf("%d",&c[i]); for(i=0;i<1011;i++) s[i]=i+1; sort(c,c+b); for(i=0;i<1011;i++) { if(c[i]!=s[i]&&sum==0) {printf("%d",s[i]);sum++;} else if(c[i-1]!=s[i]&&sum==1) {printf(" %d\n",s[i]);break;} } } } return 0; }