Submission #200463

# Submission time Handle Problem Language Result Execution time Memory
200463 2020-02-06T21:32:17 Z Sorting Strongbox (POI11_sej) C++14
70 / 100
1000 ms 6500 KB
#include <bits/stdc++.h>

using namespace std;

vector<long long > divisors, m;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	long long n, k;
	cin >> n >> k;

	m.resize(k);
	for(int i = 0; i < k; ++i)
		cin >> m[i];

	
	for(long long d = 1; d * d <= n; ++d){
		if(n % d == 0){
			divisors.push_back(d);
			if(n / d != d)
				divisors.push_back(n / d);
		}
	}

	sort(divisors.begin(), divisors.end());
	for(long long d: divisors){
		if(m[k - 1] % d != 0)
			continue;

		bool ok = true;
		for(int i = 0; i < k - 1; ++i){
			if(m[i] % d == 0){
				ok = false;
				break;
			}
		}

		if(ok){
			cout << n / d << "\n";
			return 0;
		}
	}

	cout << "0\n";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 380 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 376 KB Output is correct
2 Correct 6 ms 376 KB Output is correct
3 Correct 6 ms 376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 376 KB Output is correct
2 Correct 16 ms 504 KB Output is correct
3 Correct 14 ms 380 KB Output is correct
4 Correct 15 ms 504 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 47 ms 376 KB Output is correct
2 Correct 82 ms 632 KB Output is correct
3 Correct 106 ms 380 KB Output is correct
4 Correct 84 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 376 KB Output is correct
2 Correct 92 ms 760 KB Output is correct
3 Correct 105 ms 504 KB Output is correct
4 Correct 65 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 82 ms 376 KB Output is correct
2 Correct 104 ms 632 KB Output is correct
3 Correct 107 ms 504 KB Output is correct
4 Correct 83 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 90 ms 376 KB Output is correct
2 Correct 107 ms 760 KB Output is correct
3 Correct 105 ms 376 KB Output is correct
4 Correct 104 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 76 ms 376 KB Output is correct
2 Correct 106 ms 376 KB Output is correct
3 Correct 104 ms 376 KB Output is correct
4 Correct 109 ms 632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 103 ms 2168 KB Output is correct
2 Correct 138 ms 2552 KB Output is correct
3 Execution timed out 1089 ms 2552 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 95 ms 4472 KB Output is correct
2 Correct 145 ms 5240 KB Output is correct
3 Execution timed out 1088 ms 4088 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 86 ms 5384 KB Output is correct
2 Correct 159 ms 6264 KB Output is correct
3 Execution timed out 1055 ms 5112 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 139 ms 4856 KB Output is correct
2 Correct 159 ms 6500 KB Output is correct
3 Execution timed out 1010 ms 5240 KB Time limit exceeded
4 Halted 0 ms 0 KB -