A. Year of University Entrance

通过学生加入的特定社交网络群组来推断该学生的大学入学年份。输入包含学生加入的群组数量及其对应的大学入学年份,输出则是学生的大学入学年份。

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

There is the faculty of Computer Science in Berland. In the social net "TheContact!" for each course of this faculty there is the special group whose name equals the year of university entrance of corresponding course of students at the university.

Each of students joins the group of his course and joins all groups for which the year of student's university entrance differs by no more than x from the year of university entrance of this student, where x — some non-negative integer. A value x is not given, but it can be uniquely determined from the available data. Note that students don't join other groups.

You are given the list of groups which the student Igor joined. According to this information you need to determine the year of Igor's university entrance.

Input

The first line contains the positive odd integer n (1 ≤ n ≤ 5) — the number of groups which Igor joined.

The next line contains n distinct integers a1, a2, ..., an (2010 ≤ ai ≤ 2100) — years of student's university entrance for each group in which Igor is the member.

It is guaranteed that the input data is correct and the answer always exists. Groups are given randomly.

Output

Print the year of Igor's university entrance.

Examples
input
3
2014 2016 2015
output
2015
input
1
2050
output
2050
Note

In the first test the value x = 1. Igor entered the university in 2015. So he joined groups members of which are students who entered the university in 2014, 2015 and 2016.

In the second test the value x = 0. Igor entered only the group which corresponds to the year of his university entrance.



思路:
看样例的时候还是一脸懵逼。好吧,我承认我做题少。。。但是吧,我勇敢的猜了一下。
应为n是正奇数,再加上样例和我想的一样,所以就大胆交了一发,A 了。。。
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<stack>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
int a[10];
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        memset(a,0,sizeof(a));
        for(int i=1; i<=n; i++)
            scanf("%d",&a[i]);
        sort(a+1,a+n+1);
        printf("%d\n",a[(1+n)/2]);
    }
}



### 关于 `self.exit` 和 `self.entrance` 的赋值 在 Python 中,类的实例属性可以通过 `self` 进行访问和修改。当提到 `self.exit` 或 `self.entrance` 时,通常是在定义一个类的方法内部操作这些属性[^1]。 如果需要初始化或设置默认值给 `exit` 和 `entrance` 属性,可以利用字典方法 `.setdefault()` 来实现更简洁的操作。例如: ```python class ExampleClass: def __init__(self, key_exit, key_entrance, get_value_func): self.attributes = {} self.set_attribute(key_exit, 'exit', get_value_func) self.set_attribute(key_entrance, 'entrance', get_value_func) def set_attribute(self, key, attr_name, default_func): value = self.attributes.setdefault(key, default_func(key)) setattr(self, attr_name, value) ``` 上述代码展示了如何通过自定义函数来动态设定对象的属性值,并将其存储到字典中以便后续使用。这里的关键在于调用了 `setattr` 函数以及字典的 `.setdefault()` 方法。 对于为何不采用类似于其他语言中的 `switch/case` 结构,在 Python 设计哲学里提倡简单性和可读性,因此推荐使用字典映射或者条件分支语句替代复杂的多路判断逻辑[^2]。 尽管如此,从 Python 3.10 开始引入了结构化模式匹配 (Structural Pattern Matching),即 `match-case` 语法作为新的控制流工具之一用于处理多种情况下的数据解包与比较需求。 #### 示例解释 假设我们有一个场景需要记录某个建筑物的不同入口 (`entrance`) 及出口(`exit`) 并关联特定的功能,则可以用如下方式创建此类并完成相应属性分配: ```python def generate_default(name): return f"default_{name}" building = ExampleClass('main_door', 'side_gate', generate_default) print(building.exit) # Output: main_door's corresponding value or generated one. print(building.entrance) # Output: side_gate's corresponding value or generated one. ``` 此例子说明了即使键不存在也能自动获取预设好的缺省返回项从而顺利完成整个流程配置过程.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值