-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcaramelle.cpp
More file actions
51 lines (38 loc) · 1.06 KB
/
caramelle.cpp
File metadata and controls
51 lines (38 loc) · 1.06 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// NOTA: si raccomanda di usare questo template anche se non lo si capisce completamente.
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
// decommenta le due righe seguenti se vuoi leggere/scrivere da file
// ifstream cin("caramelle_input_1.txt");
// ofstream cout("output.txt");
int T;
cin >> T;
for (int test = 1; test <= T; ++test) {
int N;
cin >> N;
vector<long long> V(N);
for (int i = 0; i < N; ++i)
cin >> V[i];
// INSERISCI IL TUO CODICE QUI
bool multiplo;
long long c = *max_element (V.begin(), V.end());
while (true) {
multiplo = true;
for (int i=0; i<N; i++) {
if (c % V[i] != 0) {
multiplo = false;
break;
}
}
if (multiplo) break;
else c ++;
}
cout << "Case #" << test << ": ";
cout << c << endl;
}
return 0;
}