load all div 3 contests
This commit is contained in:
parent
cdf73b9909
commit
52068dbf9a
581 changed files with 2846 additions and 472 deletions
94
codeforces/19/19txt
Normal file
94
codeforces/19/19txt
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
A. Alternating Sum of Numbers
|
||||
time limit per test
|
||||
2 seconds
|
||||
memory limit per test
|
||||
256 megabytes
|
||||
input
|
||||
standard input
|
||||
output
|
||||
standard output
|
||||
You are given a sequence of integers. Output the alternating sum of this sequence. In other words, output a1−a2+a3−a4+a5−…
|
||||
a
|
||||
1
|
||||
−
|
||||
a
|
||||
2
|
||||
+
|
||||
a
|
||||
3
|
||||
−
|
||||
a
|
||||
4
|
||||
+
|
||||
a
|
||||
5
|
||||
−
|
||||
…
|
||||
. That is, the signs of plus and minus alternate, starting with a plus.
|
||||
|
||||
Input
|
||||
The first line of the test contains one integer t
|
||||
t
|
||||
(1≤t≤1000
|
||||
1
|
||||
≤
|
||||
t
|
||||
≤
|
||||
1000
|
||||
) — the number of test cases. Then follow t
|
||||
t
|
||||
test cases.
|
||||
|
||||
The first line of each test case contains one integer n
|
||||
n
|
||||
(1≤n≤50
|
||||
1
|
||||
≤
|
||||
n
|
||||
≤
|
||||
50
|
||||
) — the length of the sequence. The second line of the test case contains n
|
||||
n
|
||||
integers a1,a2,…,an
|
||||
a
|
||||
1
|
||||
,
|
||||
a
|
||||
2
|
||||
,
|
||||
…
|
||||
,
|
||||
a
|
||||
n
|
||||
(1≤ai≤100
|
||||
1
|
||||
≤
|
||||
a
|
||||
i
|
||||
≤
|
||||
100
|
||||
).
|
||||
|
||||
Output
|
||||
Output t
|
||||
t
|
||||
lines. For each test case, output the required alternating sum of the numbers.
|
||||
|
||||
Example
|
||||
Input
|
||||
Copy
|
||||
4
|
||||
4
|
||||
1 2 3 17
|
||||
1
|
||||
100
|
||||
2
|
||||
100 100
|
||||
5
|
||||
3 1 4 1 5
|
||||
Output
|
||||
Copy
|
||||
-15
|
||||
100
|
||||
0
|
||||
10
|
||||
Loading…
Add table
Add a link
Reference in a new issue