CodeForces 104 B 猜答案

来源:互联网 发布:上海税友有哪些软件 编辑:程序博客网 时间:2024/05/16 04:52

TestingPants for Sadness p
Time Limit: 2000MS Memory Limit: 262144KB 64bit IO Format: %I64d& %I64u

[Submit]  [GoBack]   [Status]

Description

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

The test consists of n questions; thequestions are to be answered strictly in the order in which theyare given, from question 1 toquestion n.Question icontains ai answervariants, exactly one of them is correct.

A click is regarded as selecting any answer in any question. Thegoal is to select the correct answer for each ofthe n questions. IfVaganych selects a wrong answer for some question, then allselected answers become unselected and the test starts from thevery beginning, from question 1 again. But Vaganychremembers everything. The order of answers for each question andthe order of questions remain unchanged, as well as the questionand answers themselves.

Vaganych is very smart and his memory is superb, yet he isunbelievably unlucky and knows nothing whatsoever about the test'stheme. How many clicks will he have to perform in the worstcase?

Input

The first line contains a positiveinteger n (1 ≤ n ≤ 100). Itis the number of questions in the test. The second line containsspace-separated n positiveintegersai (1 ≤ ai ≤ 109), the number of answer variants toquestion i.

Output

Print a single number — the minimal number of clicks needed topass the test it the worst-case scenario.

Please do not use the %lld specificator to read or write 64-bitintegers in С++. It is preferred to use the cin, cout streams orthe %I64d specificator.

Sample Input

Input
21 1
Output
2
Input
22 2
Output
5
Input
110
Output
10

Hint

Note to the second sample. In the worst-case scenario you willneed five clicks:

  • the first click selects the first variant to the firstquestion, this answer turns out to be wrong.
  • the second click selects the second variant to the firstquestion, it proves correct and we move on to the secondquestion;
  • the third click selects the first variant to the secondquestion, it is wrong and we go back to question 1;
  • the fourth click selects the second variant to the firstquestion, it proves as correct as it was and we move on to thesecond question;
  • the fifth click selects the second variant to the secondquestion, it proves correct, the test is finished.

[Submit]  [GoBack]   [Status]

#include<iostream>#include<stdio.h>#include<cmath>const int MAX=105;__int64 a[MAX];using namespace std;int main(){   int n,i;   bool f=true;   __int64 sum,temp;   while(scanf("%d",&n)!=EOF)   {                            scanf("%I64d",&a[1]);          if(n==1) { printf("%I64d\n",a[1]);continue;}         sum=a[1];           for(i=2;i<=n;i++)           {                  scanf("%I64d",&a[i]);          temp=a[i]+(a[i]-1)*(i-1);                   sum+=temp;           }       printf("%I64d\n",sum);   }return 0;}

0 0
原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 散热硅胶干了怎么办 电脑打不开pdf文件怎么办 文件变成快捷方式打不开怎么办 ai文件打不开了怎么办 电脑下载了病毒软件怎么办 打嗝停不下来怎么办 咳嗽停不下来怎么办 电动机停不下来怎么办 电脑所有程序都打不开怎么办 机顶盒画面卡顿怎么办 电脑画面卡顿怎么办 鞋舌头跑偏怎么办 球球大作战老卡怎么办 孩子被打却不敢还手怎么办? 自卫砍伤了人怎么办 系统还原节点黑屏了怎么办 我惹事了要被打怎么办 诛仙宠物太多怎么办 笔记本玩lolfps低怎么办 lol延迟有42怎么办 软件安装后黑屏怎么办 汽车脚垫翘边怎么办 晴季寿司会员怎么办 理财产品跑路了怎么办 宝宝足跟血异常怎么办 孩子足跟血异常怎么办 打印机显示用户干预怎么办 打印机脱机状态怎么办win10 电脑打印机显示脱机怎么办 佳能打印机显示脱机怎么办 汽车说明书丢了怎么办 oppo手机刷机后内存不足怎么办 电脑运行太慢怎么办 台式电脑卡慢怎么办 touch炫舞不记得区怎么办 产能过剩是带怎么办 裸辞找不到工作怎么办 30岁找不到工作怎么办 20岁找不到工作怎么办 年轻人一直找不到工作怎么办 经济不好的时候怎么办