CodeForces 440A Forgotten Episode

本文主要讲述了Polycarpus在观看一季包含n集的电视剧"Graph Theory"时,遗漏了最后一集。他已经观看了n-1集,通过已观看的集数列表,我们需要找出他忘记看的那集。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

A. Forgotten Episode
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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?

Input

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.

Output

Print the number of the episode that Polycarpus hasn't watched.

Sample test(s)
Input
10
3 8 10 1 7 9 6 5 2
Output
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;
}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值