답안 #1013366

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013366 2024-07-03T12:57:46 Z vjudge1 Strongbox (POI11_sej) C++17
100 / 100
389 ms 4440 KB
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
namespace debug { template <class c> struct rge { c b, e; }; template <class c> rge<c> range(c i, c j) { return rge<c>{i, j}; } template <class c> char spk(...); template <class c> auto spk(c* a) -> decltype(cerr << *a, 0); struct stream { ~stream() { cerr << endl; } template <class c> typename enable_if <sizeof spk<c>(0) != 1, stream&>::type operator<<(c i) { cerr << boolalpha << i; return *this; } template <class c> typename enable_if <sizeof spk<c>(0) == 1, stream&>::type operator<<(c i) { return *this << range(begin(i), end(i)); } template <class a, class b> stream& operator<<(pair <a,b> p) { return *this << "(" << p.first << ", " << p.second << ")"; } template <class c> stream& operator<<(rge<c> d) { *this << "["; for (auto it=d.b; it!=d.e; it++) *this << ", " + 2 * (it == d.b) << *it; return *this << "]"; } stream& _dbg(const string& s, int i, int b) { return *this; } template <class c, class ... cs> stream& _dbg(const string& s, int i, int b, c arg, cs ... args) { if (i == (int)(s.size())) return (*this << ": " << arg); b += (s[i] == '(') + (s[i] == '[') + (s[i] == '{') - (s[i] == ')') - (s[i] == ']') - (s[i] == '}'); return (s[i] == ',' && b == 0) ? (*this << ": " << arg << "     ")._dbg(s, i + 1, b, args...) : (s[i] == ' ' ? *this : *this << s[i])._dbg(s, i + 1, b, arg, args...); } };}
#define dout debug::stream()
#define dbg(...) ((dout << ">> ")._dbg(#__VA_ARGS__, 0, 0, __VA_ARGS__))
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define ss(x) ((int)((x).size()))
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(b);i>=(a);i--)
#define upgrade cin.tie(0)->sync_with_stdio(0);
template <class p, class q> pair<p,q> operator-(pair<p,q> a, pair<p,q> b) { return mp(a.f - b.f, a.s - b.s); }
template <class p, class q> pair<p,q> operator+(pair<p,q> a, pair<p,q> b) { return mp(a.f + b.f, a.s + b.s); }
template <class p, class q> void umin(p &a, const q &b) { if (a > b) a = b; }
template <class p, class q> void umax(p &a, const q &b) { if (a < b) a = b; }
using lf = long double;
using ll = long long;
using cll = const ll;
using cint = const int;

bool check(ll d, vector <ll>& vec)
{
	for (ll m : vec){
		if (m % d == 0){
			return false;
		}
	}
	return true;
}

int main()
{
	ll N;
	int k;
	
	scanf("%lld%d", &N, &k);

	vector <ll> m(k);

	for (ll& x : m) scanf("%lld", &x);

	ll n = __gcd(N, m.back());
	m.pop_back();
	
	for (ll& x : m) x = __gcd(x, n);

	sort(all(m));

	m.erase(unique(all(m)), m.end());
	
	//reverse(all(m));

	vector <ll> divs;

	for (ll i = 1; i * i <= n; i++){
		if (n % i != 0) continue;
		divs.pb(i);
		if (i * i < n) divs.pb(n / i);
	}

	sort(all(divs));

//	dbg(n, divs);

	for (ll d : divs){
		if (check(d, m) == true){
			printf("%lld\n", N / d);
			return 0;
		}
	}

	assert(false);
}

Compilation message

sej.cpp: In function 'int main()':
sej.cpp:43:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   43 |  scanf("%lld%d", &N, &k);
      |  ~~~~~^~~~~~~~~~~~~~~~~~
sej.cpp:47:23: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |  for (ll& x : m) scanf("%lld", &x);
      |                  ~~~~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 0 ms 376 KB Output is correct
3 Correct 3 ms 600 KB Output is correct
4 Correct 4 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 21 ms 704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 352 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 23 ms 348 KB Output is correct
4 Correct 19 ms 600 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 24 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 26 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 16 ms 448 KB Output is correct
4 Correct 27 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 38 ms 1756 KB Output is correct
2 Correct 20 ms 1884 KB Output is correct
3 Correct 130 ms 2144 KB Output is correct
4 Correct 370 ms 2884 KB Output is correct
5 Correct 94 ms 2288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 3452 KB Output is correct
2 Correct 44 ms 3996 KB Output is correct
3 Correct 73 ms 3412 KB Output is correct
4 Correct 324 ms 2684 KB Output is correct
5 Correct 123 ms 3408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 55 ms 4040 KB Output is correct
2 Correct 50 ms 4296 KB Output is correct
3 Correct 161 ms 3844 KB Output is correct
4 Correct 370 ms 4220 KB Output is correct
5 Correct 131 ms 4180 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 52 ms 3928 KB Output is correct
2 Correct 49 ms 4440 KB Output is correct
3 Correct 221 ms 4432 KB Output is correct
4 Correct 389 ms 4180 KB Output is correct
5 Correct 143 ms 4432 KB Output is correct