Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⠄⠒⠌⠔⣱⣒⣀⣄⡀⠀⠀⠒⠁⠛⠑⠆⠀⠊⠀⠠⠢⢰⠀⠀⠀⣀⡤⢖⣽⣾⣾⣿⣿⡿⣿⣿
- ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠂⠀⠀⠀⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠨⠤⢴⣾⣴⣾⣿⣿⢿⣿⣿⣿⣿⡿⠟
- ⠀⠀⠀⠀⠀⠀⠀⠀⢀⠈⠄⠀⢀⠀⠀⠀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡀⠠⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⣿⣷⣿⣻⣿⣿⡿⠛⠁⡀⠄
- ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⡈⠁⣀⠡⠀⡁⠄⢤⡆⠀⡤⠀⡠⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠺⢿⣿⡿⠟⠋⠁⢀⠀⢂⠀⠄
- ⠀⠀⠀⠀⠀⠀⠀⠰⣒⠊⠁⠠⢀⠢⢁⠐⢆⡰⢯⡊⣆⠄⣀⣀⢀⡕⢀⠔⠀⢰⠂⠀⢀⠀⠀⠀⠀⠀⠀⢖⠋⠀⠠⠐⠈⡀⠐⡀⠄⠂
- ⠀⠀⠀⠀⠀⠀⠀⢀⣤⣛⠠⣑⡏⣰⡿⢺⢟⡭⠉⠙⡿⠐⢥⠀⠀⠀⠀⠀⠀⠈⢂⠐⠈⠀⠀⠀⠀⠀⠀⢢⡉⠠⠁⠐⠠⠐⠀⠄⠐⡀
- ⠀⠀⠀⠀⠀⠀⠀⣀⠔⠁⠠⢔⠣⢌⠢⡍⠈⠀⠀⠀⢠⠀⠀⠀⠀⠀⠄⠐⡄⠀⠀⠆⠀⠀⠀⠀⢀⢀⠠⡤⠽⠂⢀⠡⠐⠀⠡⠐⢀⠀
- ⠀⠀⠀⠀⠀⠀⠀⠉⠉⡹⠀⣤⠣⢌⢢⡁⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⠆⠀⢲⡀⠀⢠⠀⠂⠀⢔⣥⡛⢤⣶⣤⣐⠀⡀⠂⢁⠐⠀⠂⡀
- ⠀⠀⠀⠀⠀⠀⠀⠀⠴⠕⡇⢎⡗⣈⡲⠁⠀⠀⢀⡇⢸⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⢼⠀⠀⢀⡞⣥⣸⣜⣿⣳⠿⣮⣥⣶⣤⣂⠁⠐⠀
- ⠀⠀⠀⠀⠀⠀⠀⠀⢠⢴⣃⢸⣏⢍⣛⢣⡀⠀⠈⠳⢈⠀⠀⠀⠀⣀⠼⡤⠄⠈⠀⠀⠀⣾⢫⣟⣖⢸⣿⣿⣿⣻⡵⢯⣿⣿⣆⠉⠳⣶
- ⠴⢻⡒⢦⣠⣀⠤⢔⠈⢀⡀⢿⠽⡜⠟⠻⠿⠓⢤⣄⠘⢱⣤⡶⣛⣁⣤⣇⣠⡤⠀⠀⠀⡧⣾⣟⡿⢸⢛⢿⣿⣷⣻⢻⡾⣍⢏⠳⣄⠈
- ⠀⠀⠙⠃⠢⢈⠧⡀⢳⡀⢱⡀⢶⢣⡣⢍⢩⡘⠯⢽⠀⠘⠁⠒⠈⠉⠉⢛⠉⠀⠀⠀⠀⣧⡞⣯⣼⡯⢌⠎⣿⣷⢯⣟⡽⣿⢘⣿⣿⣷
- ⠀⠀⠀⠀⠀⠉⠰⠌⡆⣷⠈⡆⠉⢰⣷⣊⠴⠡⠎⡽⠀⠀⠀⠀⠀⠀⠀⢸⠀⠀⠀⠀⠀⢾⢻⣿⢹⠀⠈⢎⣿⣿⣻⢮⣟⣧⣿⣿⣿⢿
- ⡼⡳⡄⢀⡶⡀⠨⡁⠓⡄⡒⣏⣾⢻⣽⣷⡊⡕⢣⠹⢤⡤⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⢟⣸⢿⢸⢀⠀⠘⣿⣿⣽⣻⢾⣽⡏⡕⣯⠞
- ⣙⠻⣧⢸⣗⣣⠀⢸⣴⣷⡟⣯⠷⠛⣼⡿⣿⡜⢤⠓⣼⠤⠄⠀⠠⠀⡀⠀⠀⠀⣠⠔⡱⣪⠞⠘⠈⠁⠀⠀⣿⣿⡷⣯⣟⣾⣗⢷⢸⡹
- ⠈⣽⡟⠈⠷⠏⢠⣟⣿⠗⠋⠁⠀⣼⡿⣽⣳⣿⣦⡙⣌⢒⠲⠲⠤⠀⠀⢀⡤⡚⡔⣊⡱⠋⡂⠀⠀⠀⠀⠀⣽⣿⣟⣷⣻⣞⣿⣸⠀⣹
- ⣴⡿⠗⣦⡀⠀⢠⡟⠁⠀⠀⠀⣼⡿⣽⣳⣿⣿⣿⣧⣜⢢⡆⣀⣀⡴⠞⣍⠲⡱⢘⡤⠁⡜⠀⠀⠀⡄⠀⠀⣾⣿⣿⣳⣟⣾⣻⣏⠀⢰
- ⡟⡴⢂⠈⢧⠜⣫⣾⣶⣄⠀⣸⣿⣽⣳⣯⣿⣿⣿⣿⣿⣏⠹⣹⣶⣉⠞⣠⢣⡕⠉⢀⣼⠃⠀⠀⠀⣻⡄⠀⣻⣿⣿⣿⣞⣷⣻⢿⣿⣦
- ⣇⠐⠠⡱⢢⣾⣿⣽⣟⣾⣷⣿⣳⢯⣷⡿⢸⣿⣿⣿⣿⣇⢣⠧⡈⠅⠉⠉⠁⠀⢀⣜⠆⠀⠀⠀⠀⢹⡜⣄⣻⣿⣿⣿⣞⡷⣯⣿⣿⣻
- ⢳⣭⠟⡠⣹⣿⣿⣟⣾⣿⣟⣷⣻⣯⣿⠋⢸⣿⣿⣿⣿⡷⢮⠥⢹⣆⠀⠀⠀⣔⣣⠾⠔⠒⠒⠚⠉⠉⠁⢀⣿⣿⣿⣿⣿⡽⣷⢯⣿⣿
- ⠀⣿⣸⣴⣿⣿⣳⣿⣿⣳⡿⣾⣽⣯⢻⠀⢸⣿⣿⣿⣿⣇⠻⠀⠀⠈⠁⠀⠈⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣻⣟⣷⣿
- ⣾⣿⣿⣿⣿⣽⣿⣟⣾⢿⣽⠟⣹⠁⢸⠀⢸⣿⣿⣿⣿⡇⣏⠀⠀⠀⢀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣄⡄⣿⣿⣿⣿⣿⣿⣿⣷⢿⣻⣾
- ⣿⣿⣿⣿⡿⣯⣷⡿⣯⡿⠋⠀⠀⠀⣸⠀⠰⣿⣿⣿⣿⣏⠼⠀⠀⠀⢰⠀⠀⠀⠀⠀⠀⠀⠀⢀⡄⠀⢠⣿⣿⣿⣿⣿⣿⠇⠻⣟⣯⣿
- ⣿⣿⣿⢯⣿⡿⣽⡿⠟⡃⠀⡀⠀⠀⡆⠀⠀⣿⣿⣿⣿⡧⢫⡅⠀⠀⠈⡄⠀⠀⠀⠀⠀⠀⠸⠃⠂⠀⣾⣿⣿⣿⣿⣿⡟⠀⡠⢹⢻⣿
- ⣿⣿⣽⣿⣿⠝⠁⠀⠀⢧⠀⡆⠀⠀⠀⠀⠀⣿⣿⣿⣿⣗⢣⢞⣄⠀⠀⢟⣆⠀⠀⠀⢠⠜⠁⠀⠀⣸⣿⣿⣿⣿⣿⡿⠁⠀⢇⢸⠀⠙
- */
- // IAM Batman
- // Vengeance
- // Maybe im the problem
- #include <bits/stdc++.h>
- #define ll long long
- #define Time cerr << "Time Taken: " << (float)clock() / CLOCKS_PER_SEC << " Secs" \<< "\n";
- #define ln cout << endl;
- #define c(n) cout << n;
- #define fix cout << fixed << setprecision(6);
- #define sz(x) int(x.size())
- #define loop(n) for (int i = 0; i < n; i++)
- #define loop1(n) for (int i = 1; i < n; i++)
- #define vi vector<int>
- #define vll vector<long long>
- #define all(s) s.begin(), s.end()
- #define srt(arr, n) sort(arr, arr + n);
- #define prefixsum(arr, n) \
- for (int i = 1; i <= n; i++) \
- { \
- arr[i] += arr[i - 1]; \
- }
- #define upper(s) transform(all(s), s.begin(), ::toupper);
- #define lower(s) transform(all(s), s.begin(), ::tolower);
- #define pi 3.141592653
- #define pb push_back
- #define vc vector<char>
- #define sz(s) s.size()
- #define supra_mk4 ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
- #define ulli unsigned ll int
- using namespace std;
- void Bassel()
- {
- // supra_mk4
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin),
- freopen("output.txt", "w", stdout);
- #endif
- }
- void solve1()
- {
- int n;
- cin >> n;
- int a[n];
- int sum = 0;
- loop(n)
- {
- cin >> a[i];
- sum += a[i];
- }
- int avg = sum / n;
- // cout<<"avg:"<<avg<<" ";
- int cost = 0;
- for (int i = 0; i < n; i++)
- {
- cost += pow((a[i] - avg), 2);
- }
- cout << cost << "\n";
- }
- int main()
- {
- Bassel();
- supra_mk4 int t = 1;
- cin >> t;
- while (t--)
- {
- solve1();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement