Day 1: Adding all Together
Yusuf is a professional nature photographer. Recently, he went to Toros Mountains to take some photos. There are mountains where the th one has height. The company will pay Yusuf for each photo he brings. Money paid for a photo is calculated by sum of heights of mountains in it. Since Yusuf likes money, he decided to take photos as much as he can. We can represent a photo as a contiguous segment of mountains. Company will only pay once for same photos, we call two photos different if one of them contain a mountain where other does not contain it. Calculate the money Yusuf will get if he takes all different photos.
Formally, you are given an array consisting of integers. Calculate sum of values of all subarrays.
Subarray is some contiguous segment of the array. We define the value of a subarray as the sum of integer values in it.
Answer may not be fit into 32 bit integers.
Note: If you are using C/C++, answer may not be fit into int datatype. Use long long instead.
Yusuf, profesyonel bir doğa fotoğrafçısıdır. Geçenlerde fotoğraf çekmek için Toros Dağları'na gitti. ' inci yüksekliğin ai yüksekliğine sahip olduğu dağ vardır. Şirket getirdiği her fotoğraf için Yusuf'a ödeme yapacak. Bir fotoğraf için ödenen para, içindeki dağların yüksekliklerinin toplamı ile hesaplanacaktır. Yusuf parayı sevdiği için elinden geldiğince fotoğraf çekmeye karar verdi. Bir fotoğrafı bitişik bir dağ parçası olarak temsil edebiliriz. Şirket aynı fotoğraflar için yalnızca bir kez ödeme yapacak. Bir fotoğrafta dağ varsa diğerinde yoksa, iki fotoğrafa farklı diyoruz. Yusuf'un tüm farklı fotoğrafları çekmesi durumunda alacağı parayı hesaplayın.
Resmi olarak, size tam sayıdan oluşan bir dizi verilir. Tüm alt dizilerin değerlerinin toplamını hesaplayın.
Alt dizi, dizinin bazı bitişik bölümüdür. Bir alt dizinin değerini, içindeki tamsayı değerlerinin toplamı olarak tanımlanır.
Cevap 32 bitlik tam sayılara sığmayabilir.
Not: C / C ++ kullanıyorsanız, yanıt int veri türüne sığmayabilir. Bunun yerine long long veri tipini kullanın.
Input Format
First line will consist of one integer , the number of mountains.
Second line will consist of integers, the heights of the mountains.
İlk satır sayısından yani dağların sayısından oluşacaktır.
İkinci satır tane tam sayıdan yani dağların yüksekliklerinden oluşacaktır.
Constraints
for is the element of array.
Output Format
Output one value, the answer to the question.
Output sorunun cevabı olan bir değerden oluşur.
Sample Input 0
3
1 2 1
Sample Output 0
14
Explanation 0
The possible different photos are [1], [1, 2], [1, 2, 1], [2], [2, 1], [1].
The values of these photos are respectively.
And their sum is .
Olası farklı fotoğraflar [1], [1, 2], [1, 2, 1], [2], [2, 1], [1].
Bu fotoğrafların değerleri sırasıyla 'dir.
Ve toplamları .
Sample Input 1
8
34 53 88 25 47 96 92 12
Sample Output 1
7150
xxxxxxxxxx
with Ada.Text_IO, Ada.Integer_Text_IO;
use Ada;
procedure Solution is
-- Enter your code here. Read input from STDIN. Print output to STDOUT
end Solution