| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1332038 | Andrey | Gingerbread (BOI25_gcd) | C++20 | 71 ms | 4640 KiB |
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b) {
if(b == 0) {
return a;
}
return gcd(b,a%b);
}
vector<int> haha(0);
bool dude(int d, int br) {
if(d == haha.size()) {
int e = 0;
for(int i = 0; i < haha.size(); i++) {
e = gcd(e,haha[i]);
}
if(e == 1) {
return 1;
}
return 0;
}
for(int i = 0; i <= br; i++) {
haha[d]+=i;
if(dude(d+1,br-i)) {
return true;
}
haha[d]-=i;
}
return false;
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n;
cin >> n;
for(int i = 0; i < n; i++) {
int a;
cin >> a;
haha.push_back(a);
}
int d = 0;
for(int i = 0; i < n; i++) {
d = gcd(d,haha[i]);
}
if(d == 1) {
cout << 0;
return 0;
}
if(n > 15) {
cout << 1;
return 0;
}
for(int i = 1; i < 1000; i++) {
if(dude(0,i)) {
cout << i;
return 0;
}
}
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
