我最喜歡念書了!
2000頁的課本耶!
我下一頁應該要念哪一頁呢QQ
輸入說明 :
多組輸入以EOF結束
每組輸入一開始有一個數字n(0 <= n <= 1000)代表你以前看過幾頁(可能重複)
接下來n個1~2000的正整數代表你看過哪幾頁
輸出說明 :
一個數字,代表你下一頁應該看哪一頁
也就是這本書裡面第一頁你沒看過的
範例輸入 :
5
1 3 4 5 6
4
1 2 3 4
5
2 3 4 5 6
範例輸出 :
2
5
1
程式碼 :
#include <stdio.h>
int main(int argc, const char * argv[])
{
int i,n,temp,arr[2001];
while (scanf("%d",&n)==1) {
for (i=1; i<2001; i++)
arr[i] = 0;
for (i=0; i<n; i++) {
scanf("%d",&temp);
arr[temp] = 1;
}
for (i=1; arr[i]==1; i++);
printf("%d\n",i);
}
return 0;
}
http://zerojudge.tw/ShowProblem?problemid=a282
沒有留言:
張貼留言