| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1364283 | SmuggingSpun | Gingerbread (BOI25_gcd) | C++20 | 5 ms | 824 KiB |
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
const int lim = 1e5 + 5;
int n, g = 0, a[lim];
bool backtrack(int p, int cnt){
if(p == n){
for(int i = g = 0; i < n; i++){
g = __gcd(g, a[i]);
}
return g == 1;
}
for(int i = 0; i <= cnt; i++){
a[p] += i;
if(backtrack(p + 1, cnt - i)){
return true;
}
a[p] -= i;
}
return false;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
cin >> n;
for(int i = 0; i < n; g = __gcd(g, a[i++])){
cin >> a[i];
}
if(g == 1){
return cout << 0, 0;
}
if(n > 15){
return cout << 1, 0;
}
for(int i = 1; true; i++){
if(backtrack(0, i)){
return cout << i, 0;
}
}
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
