forked from Mohammed-Shoaib/Coding-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathE0060.cpp
More file actions
36 lines (32 loc) · 624 Bytes
/
E0060.cpp
File metadata and controls
36 lines (32 loc) · 624 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Problem Code: CUTPIZ
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
using namespace std;
int cuttingPizza(vector<int> a) {
int gcd, cuts;
sort(a.begin(), a.end());
gcd = 360;
if(a[0] != 0)
transform(a.begin(), a.end(), a.begin(), bind2nd(minus<int>(), a[0]));
for(int i=0 ; i<a.size() ; i++)
gcd = __gcd(a[i], gcd);
cuts = 360/gcd - a.size();
return cuts;
}
int main() {
int T, n, num;
vector<int> a;
cin >> T;
while(T--) {
cin >> n;
for(int i=0 ; i<n ; i++) {
cin >> num;
a.push_back(num);
}
cout << cuttingPizza(a) << endl;
a.clear();
}
return 0;
}