You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
600 B
C++
26 lines
600 B
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
int dx[] = {0, 1, 0, -1};
|
|
int dy[] = {1, 0, -1, 0};
|
|
int main()
|
|
{
|
|
ios::sync_with_stdio(false);
|
|
int T, n;
|
|
cin >> T;
|
|
for (int t = 1; t <= T; t++)
|
|
{
|
|
cin >> n;
|
|
long long x = 0, y = 0, l;
|
|
for (int i = 0; i < n; i++)
|
|
{
|
|
cin >> l;
|
|
x += dx[i & 3] * l;
|
|
y += dy[i & 3] * l;
|
|
}
|
|
cout << "Case #" << t << ':' << x * x + y * y << endl;
|
|
}
|
|
return 0;
|
|
}
|