CF103A.Testing Pants for Sadness
普及-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 a__i 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?
平均水准的矿工瓦甘奇参加了进修课程。矿工一旦完成课程,就必须参加考试。其中最难的一门是名为“悲伤裤子测试”的计算机考试。
该考试共包含 n 道题目;考生必须严格按照题目给出的顺序,从第 1 题到第 n 题依次作答。第 i 题有 ai 个选项,其中恰好有一个是正确答案。
一次“点击”指在任意一题中选择任意一个选项。目标是为全部 n 道题目均选出正确答案。若瓦甘奇在某道题中选错了答案,则所有已选答案将被清空,考试将重新从第 1 题开始。但瓦甘奇拥有过目不忘的记忆力:每道题的选项顺序、各题的顺序、题目本身及选项内容均保持不变。
瓦甘奇非常聪明,记忆力超群,然而他倒霉到了极点,对考试主题完全一无所知。那么,在最坏情况下,他总共需要进行多少次点击?
输入格式
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 a__i (1 ≤ a__i ≤ 109), the number of answer variants to question i.
第一行包含一个正整数 n(1≤n≤100),表示测试题的数量。
第二行包含 n 个由空格分隔的正整数 ai(1≤ai≤109),表示第 i 道题的答案选项数量。
输出格式
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 С++. It is preferred to use the cin, cout streams or the %I64d specificator.
输出一个整数——在最坏情况下通过测试所需的最少点击次数。
请注意:在 C++ 中,请勿使用 %lld 格式说明符来读取或写入 64 位整数。推荐使用 cin、cout 流,或使用 %I64d 格式说明符。
输入输出样例
输入#1
2 1 1
输出#1
2
输入#2
2 2 2
输出#2
5
输入#3
1 10
输出#3
10
说明/提示
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.
第二个样例的说明:在最坏情况下,你需要五次点击:
- 第一次点击选择第一个问题的第一个选项,该答案被判定为错误;
- 第二次点击选择第一个问题的第二个选项,该答案被判定为正确,于是进入第二个问题;
- 第三次点击选择第二个问题的第一个选项,该答案被判定为错误,于是返回第一个问题;
- 第四次点击再次选择第一个问题的第二个选项,该答案仍被判定为正确,于是再次进入第二个问题;
- 第五次点击选择第二个问题的第二个选项,该答案被判定为正确,测试结束。
输入解题思路,AI测评打分。不知道怎么写?