Submission #308323

# Submission time Handle Problem Language Result Execution time Memory
308323 2020-09-30T22:57:19 Z luciocf Strongbox (POI11_sej) C++14
0 / 100
1000 ms 65540 KB
#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

sej.cpp: In function 'int main()':
sej.cpp:15:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   15 |  scanf("%lld %d", &n, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~~
sej.cpp:18:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   18 |   scanf("%lld", &a[i]);
      |   ~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Runtime error 1 ms 384 KB Execution killed with signal 8 (could be triggered by violating memory limits)
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 532 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 933 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1095 ms 51112 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 512 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 384 KB Execution killed with signal 8 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 51300 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1087 ms 50384 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1 ms 256 KB Time limit exceeded (wall clock)
2 Halted 0 ms 0 KB -