답안 #167923

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
167923 2019-12-10T20:04:01 Z Thuleanx Strongbox (POI11_sej) C++14
100 / 100
236 ms 6148 KB
#include <bits/stdc++.h>
using namespace std;

unordered_set<long long> vis;
vector<int> primes;
long long ans;

void brute_force(long long v, bool save) {
	if (save)
		ans = min(ans, v);
	vis.insert(v);
	for (long long p : primes)
		if (v%p==0 && !vis.count(v / p))
			brute_force(v/p, save);
}

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

	int n; long long m; cin>>m>>n;
	long long a[n];
	for (int i = 0; i < n; i++) {
		cin>>a[i];
		a[i] = __gcd(a[i], m);
	}
	for (long long p = 2, x = a[n-1]; p*p <= x; p++) {
		if (x%p == 0) {
			primes.push_back(p);
			while (x%p == 0)
				x /= p;
		}
		if ((p+1)*(p+1)>x && x>1)
			primes.push_back(x);
	}
	ans = m;
	for (int i = 0; i < n; i++)
		brute_force(__gcd(a[i], a[n-1]), i == n-1);
	cout << m/ans << endl;

	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 3 ms 504 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 14 ms 376 KB Output is correct
4 Correct 6 ms 760 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 12 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 125 ms 424 KB Output is correct
4 Correct 11 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 12 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 380 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Correct 12 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 89 ms 376 KB Output is correct
4 Correct 13 ms 1148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 72 ms 2168 KB Output is correct
2 Correct 72 ms 2168 KB Output is correct
3 Correct 82 ms 2680 KB Output is correct
4 Correct 123 ms 3872 KB Output is correct
5 Correct 83 ms 2936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 151 ms 4608 KB Output is correct
2 Correct 187 ms 4956 KB Output is correct
3 Correct 145 ms 4344 KB Output is correct
4 Correct 126 ms 4016 KB Output is correct
5 Correct 151 ms 4700 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 5240 KB Output is correct
2 Correct 236 ms 6148 KB Output is correct
3 Correct 180 ms 5496 KB Output is correct
4 Correct 187 ms 5592 KB Output is correct
5 Correct 184 ms 5624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 162 ms 4856 KB Output is correct
2 Correct 236 ms 5904 KB Output is correct
3 Correct 188 ms 5380 KB Output is correct
4 Correct 193 ms 5752 KB Output is correct
5 Correct 184 ms 5624 KB Output is correct