P10100: 测试答案

传统题
2.000s 时间限制
256MB 内存限制
3 提交
1 解决

【题目描述】
【题目描述】
矿工小智参加了进修课程。一旦他完成课程,他就应该参加考试。最难的是一项名为“测试裤子是否悲伤”的电脑测试。
测试由n个问题组成;问题的回答要严格按照题目的顺序,从问题1到问题n。问题i包含ai个选项,只有一个是正确的。
现在要n个问题中的每一个问题选择正确的答案。如果小智选错了某个问题的答案,那么所有选中的答案都将被取消,测试将重新从第1个问题题开始。但是小智记得之前所做的一切选择。每个问题的答案顺序和问题的顺序以及问题和答案本身保持不变。
小智非常聪明,他的记忆力非常好,然而他却非常不幸,对考试的主题一无所知。在最坏的情况下,他需要进行多少次选择?
【输入】
第一行为正整数n(1n100)。它是测试中问题的数量。第二行包含空格分隔的n个正整数ai(1ai109),即问题i的答案选的数量。
【输出】
输出一个数字-在最坏的情况下通过测试所需的最小选择次数。
请不要使用%lld说明符在c++中读写64位整数。最好使用cincout流或%I64d说明符。
【输入样例1
2
1 1
【输出样例1
2
【输入样例2
2
2 2
【输出校例2
5
【输入样例3
1
10
【输出样例3
10
样例2说明】
第二个示例。在最坏的情况下,你将需要5次点击:
第一次点击选择第一个问题的第一个变体,这个答案是错误的。
第二次点击选择第一个问题的第二个变体,它被证明是正确的,我们继续第二个问题;
第三次点击选择第二个问题的第一个变体,这是错误的,我们回到问题1;
第四次点击选择第一个问题的第二个变体,它被证明是正确的,我们继续第二个问题;
第五次点击选择第二题的第二个变体,证明正确,测试结束。


【样例输入】复制
【样例输出】 复制
【提示】

Testing Pants for Sadness

The average miner Vaganych took refresher courses. As soon as a miner completes the courses, he should take exams. The hardest one is a computer test called "Testing Pants for Sadness".

The test consists of n questions; the questions are to be answered strictly in the order in which they are given, from question 1 to question n. Question i contains ai answer variants, exactly one of them is correct.
A click is regarded as selecting any answer in any question. The goal is to select the correct answer for each of the n questions. If Vaganych selects a wrong answer for some question, then all selected answers become unselected and the test starts from the very beginning, from question 1 again. But Vaganych remembers everything. The order of answers for each question and the order of questions remain unchanged, as well as the question and answers themselves.
Vaganych is very smart and his memory is superb, yet he is unbelievably unlucky and knows nothing whatsoever about the test's theme. How many clicks will he have to perform in the worst case?
Input
The first line contains a positive integer n (1≤n≤100). It is the number of questions in the test. The second line contains space-separated n positive integers ai (1≤ai≤109), the number of answer variants to question i.
Output
Print a single number − the minimal number of clicks needed to pass the test it the worst-case scenario.
Please do not use the %lld specificator to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specificator.
Examples
Input
2
1 1
Output
2
Input
2
2 2
Output
5
Input
1
10
Output
10
Note
Note to the second sample. In the worst-case scenario you will need five clicks:
  • the first click selects the first variant to the first question, this answer turns out to be wrong.
  • the second click selects the second variant to the first question, it proves correct and we move on to the second question;
  • the third click selects the first variant to the second question, it is wrong and we go back to question 1;
  • the fourth click selects the second variant to the first question, it proves as correct as it was and we move on to the second question;
  • the fifth click selects the second variant to the second question, it proves correct, the test is finished.

题目类型~

 

咻咻~

提交答案 状态