A8222 | Testing Pants for Sadness
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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?
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?
输入格式
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}<=10^{9}$ ), the number of answer variants to question $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.
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.
输入输出样例
输入 #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.
- 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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted