Polycarpus adores TV series. Right now he is ready to finish watching a season of a popular sitcom "Graph Theory". In total, the season has n episodes, numbered with integers from 1 to n.
Polycarpus watches episodes not one by one but in a random order. He has already watched all the episodes except for one. Which episode has Polycaprus forgotten to watch?
The first line of the input contains integer n (2 ≤ n ≤ 100000) — the number of episodes in a season. Assume that the episodes are numbered by integers from 1 to n.
The second line contains n - 1 integer a1, a2, ..., an (1 ≤ ai ≤ n) — the numbers of episodes that Polycarpus has watched. All values of ai are distinct.
Print the number of the episode that Polycarpus hasn't watched.
10 3 8 10 1 7 9 6 5 2
4#include<iostream> using namespace std; int num[100010]; int main(){ int n,k,i; while(cin>>n){ for(i=0;i<n;i++){ cin>>k; num[k]=1; } for(i=1;i<=n;i++){ if(!num[i]){ cout<<i<<endl; } } } return 0; }
本文主要讲述了Polycarpus在观看一季包含n集的电视剧"Graph Theory"时,遗漏了最后一集。他已经观看了n-1集,通过已观看的集数列表,我们需要找出他忘记看的那集。
1926

被折叠的 条评论
为什么被折叠?



