Submission #1351589

#TimeUsernameProblemLanguageResultExecution timeMemory
1351589nerrrminGingerbread (BOI25_gcd)C++20
17 / 100
0 ms344 KiB
#include<bits/stdc++.h>
#define endl '\n'
#define pb push_back
using namespace std;
const int maxn = 15;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n, a[maxn];
int main()
{
    speed();

    cin >> n;
    for (int i = 1; i <= n; ++ i)
        cin >> a[i];
    for (int ans = 0; ans <= 10; ++ ans)
    {
        int x = a[1], y = a[2];
        for (int f = 0; f <= ans; ++ f)
        {
            x = a[1] + f;
            y = a[2] + (ans - f);
            if(__gcd(x, y) == 1)
            {
                cout << ans << endl;
                return 0;
            }

        }
    }
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...