# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
308323 | luciocf | Strongbox (POI11_sej) | C++14 | 1095 ms | 65540 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3+10;
ll a[maxn];
int main(void)
{
ll n;
int k;
scanf("%lld %d", &n, &k);
for (int i = 1; i <= k; i++)
scanf("%lld", &a[i]);
ll ans = a[k];
for (ll i = 1; i*i <= a[k]; i++)
{
if (a[k]%i) continue;
ll d = i;
map<ll, bool> mark;
ll at = 0;
bool ok = 1;
while (!mark[at])
{
mark[at] = 1;
for (int j = 1; j < k; j++)
if (a[j] == at)
ok = 0;
at = (at + d)%n;
}
if (ok) ans = min(ans, d);
mark.clear();
d = a[k]/i;
at = 0;
ok = 1;
while (!mark[at])
{
mark[at] = 1;
for (int j = 1; j < k; j++)
if (a[j] == at)
ok = 0;
at = (at + d)%n;
}
if (ok) ans = min(ans, d);
}
printf("%lld\n", n/ans);
}
Compilation message (stderr)
# | 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... |
# | 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... |
# | 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... |