Codeforces 130A - Testing Pants for Sadness(解题报告)

Testing Pants for SadnessCrawling in process...
Crawling failed
Time Limit:2000MS    
Memory Limit:262144KB    
64bit IO Format:
%I64d & %I64u

Submit
Status Practice CodeForces 103A

Description

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 С++. It is preferred to use the cin, cout streams or the %I64d specificator.

Sample Input

Input

2
1 1

Output

2

Input

2
2 2

Output

5

Input

1
10

Output

10

Sample Output

Case #1: 15.707963
Case #2: 2.250778 

Hint

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.

参考代码:

#include<stdio.h>
#define ll __int64
int main()
{
	int n;
	ll a[105];
	ll sum;
	while(~scanf("%d",&n))
	{
		sum=0;
		for(int i=1;i<=n;i++)
		    scanf("%I64d",&a[i]);
		for(int i=1;i<=n;i++)
			sum+=(i-1)*(a[i]-1)+a[i];
		printf("%I64d\n",sum);
	}
	return 0;
}

版权声明:本文为博主原创文章,随便转载。

时间: 2024-12-31 21:24:51

Codeforces 130A - Testing Pants for Sadness(解题报告)的相关文章

codeforces 505A. Mr. Kitayuta&#39;s Gift 解题报告

题目链接:http://codeforces.com/problemset/problem/505/A 题目意思:给出一个长度不大于10的小写英文字符串 s,问是否能通过在字符串的某个位置插入一个字母,使得新得到的字符串成为回文串. /**************************************(又到自我反省时刻) 做的时候,通过添加一个单位使得长度增加1,找出中点,检验前一半的位置,找出对称位置替换成对应的前一半位置的字符,然后原字符串剩下的部分追加到后面,再判断回文.但是由于

codeforces 499A.Inna and Pink Pony 解题报告

题目链接:http://codeforces.com/problemset/problem/499/A 题目意思:有两种按钮:1.如果当前观看的时间是 t,player 可以自动处理下一分钟,姑且理解为跳到t+1:  2.直接跳过 x 分钟,如果player在第 t 分钟,则可以跳到 t+x.问恰好可以看完 n 部电影的最少观看时间.观看一部电影表示 li, li+1, li+2, ..., ri-1, ri 的时间都要覆盖到. 一开始做的时候想得太简单了,确实需要每部电影的所有时间,但是如果不

codeforces 510B. Fox And Two Dots 解题报告

题目链接:http://codeforces.com/problemset/problem/510/B 题目意思:给出 n 行 m 列只有大写字母组成的字符串.问具有相同字母的能否组成一个环. 很容易知道要用到深搜.暴力搜索--- 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 using namespace std; 6 7 cons

codeforces 556B. Case of Fake Numbers 解题报告

题目链接:http://codeforces.com/problemset/problem/556/B 题目意思:给出 n 个齿轮,每个齿轮有 n 个 teeth,逆时针排列,编号为0 ~ n-1.每按一次 button,每个齿轮都会有且仅有一个活动的tooth,对于偶数编号的齿轮,它下一个活动tooth是紧挨着当前tooth的逆时针方向的那个:而奇数编号的齿轮,下一个活动tooth是顺时针的那个.给出每个齿轮的活动tooth,问通过按下有限次的button,问能不能得到一个0,1,...,n-

CodeForces 501B(STL_H题)解题报告

题目链接:http://codeforces.com/problemset/problem/501/B -------------------------------------------------------------------------------- 题意:N个改名操作,要求输出最开始和最终的名字 思路:利用map的操作,读取输入之后,查找是否在key中,如果不在key中,建立新的关系.如果在key中,建立新的key-value对,擦除旧的key-value对.最终通过迭代器输出k

CodeForces 915C(DFS_E题)解题报告

题目链接:http://codeforces.com/problemset/problem/915/C --------------------------------------------------------------------------------- 题意:给你两个数 a和 b,可以打乱 a每位数的顺序,让你求满足 小于等于b 的最大值.. 思路:首先,观察到数值比较大,所以采用字符串读入的方式进行处理,通过比较字典序,交换不同位数是的保证每一次操作都是最优解. 代码: #inc

CodeForces 689B(BFS_B题)解题报告

题目链接:http://codeforces.com/problemset/problem/689/B -------------------------------------------------------------------------------- 题意:在一条直线上有n个城市,相邻两个城市之间的花费为1,但是有捷径,可以到捷径所在的点,而且只需要1的花费,捷径不能前往之前的城市. 思路:经典的,bfs打板直接过.唯一要注意的是这种情况,如4-7有捷径,所以有可能到6的最短路径为

[Codeforces Round #194 (Div. 2)] Secret 解题报告 (数学)

题目链接:http://codeforces.com/problemset/problem/334/C 题目: 题目大意: 给定数字n,要求构建一个数列使得数列的每一个元素的值都是3的次方,数列之和S大于n,且删掉数列中的任意一个元素数列之和都会小于n,最小化这个数列的长度 题解: 我们考虑从小到大枚举k,取最小的k,使得,答案就是$n/3^k+1$ 为什么呢? 我们考虑一个合法的数列,其中最小的元素是A,那么S一定是A的倍数.假设n是A的倍数,又S>n,那么S-A>=n,这样的话去掉A这个数

Codeforces Round 319 # div.1 &amp; 2 解题报告

Div. 2 Multiplication Table (577A) 题意: 给定n行n列的方阵,第i行第j列的数就是i*j,问有多少个格子上的数恰为x. 1<=n<=10^5, 1<=x<=10^9 题解: 送分题…对于每一行,判断是否存在数x即可…也可以枚举x的因子判断是否出现在表内… #include<cstdio>#include<cstring>inlineint read(){int s =0;char c;while((c=getchar())