AT_abc479_a.Odd Index Sum

入门

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an integer sequence of length NN: A=(A1,A2,…,AN)A=(A_1,A_2,\dots,A_N).
Find the sum of the odd-indexed terms of AA.
More formally, find the sum of AiA_i over all odd ii satisfying 1≤i≤N1 \le i \le N.

给你一个长度为 NN 的整数序列:A=(A1,A2,…,AN)A=(A_1,A_2,\dots,A_N)。
求 AA 中所有奇数下标项的和。
更准确地说,求满足 1≤i≤N1 \le i \le N 的所有奇数 ii 对应的 AiA_i 之和。

输入格式

The input is given from Standard Input in the following format:

NN
A1A_1 A2A_2 …\dots ANA_N

输入从标准输入中按以下格式给出:

NN
A1A_1 A2A_2 …\dots ANA_N

输出格式

Output the answer.

输出答案。

输入输出样例

  • 输入#1

    5
    3 1 4 1 5

    输出#1

    12
  • 输入#2

    6
    2 7 1 8 2 8

    输出#2

    5
  • 输入#3

    9
    100 40 30 50 20 90 100 80 60

    输出#3

    310

说明/提示

Sample 1 Explanation:
In this input, A=(3,1,4,1,5)A=(3,1,4,1,5), and the terms to be summed are A1,A3,A5A_1,A_3,A_5.
Output their sum, that is, 3+4+5=123+4+5=12.

Sample 2 Explanation:
In this input, A=(2,7,1,8,2,8)A=(2,7,1,8,2,8), and the terms to be summed are A1,A3,A5A_1,A_3,A_5.
Output their sum, that is, 2+1+2=52+1+2=5.

Constraints

  • All input values are integers.
  • 1≤N≤1001 \le N \le 100
  • 1≤Ai≤1001 \le A_i \le 100

样例 1 解释:
本输入中,A=(3,1,4,1,5)A=(3,1,4,1,5),需累加的项为 A1,A3,A5A_1,A_3,A_5。
输出它们的和,即 3+4+5=123+4+5=12。

样例 2 解释:
本输入中,A=(2,7,1,8,2,8)A=(2,7,1,8,2,8),需累加的项为 A1,A3,A5A_1,A_3,A_5。
输出它们的和,即 2+1+2=52+1+2=5。

限制条件

  • 所有输入值均为整数。
  • 1≤N≤1001 \le N \le 100
  • 1≤Ai≤1001 \le A_i \le 100

输入解题思路,AI测评打分。不知道怎么写?

首页