답안 #197384

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197384 2020-01-20T16:52:00 Z stefdasca Strongbox (POI11_sej) C++14
100 / 100
556 ms 4792 KB
#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front
#define mod 1000000007
#define dancila 3.14159265359
#define eps 1e-9

// #define fisier 1

using namespace std;

typedef long long ll;

ll n, k, m, ans = (1LL<<60);

ll cmmdc(ll a, ll b)
{
    ll c;
    while(b)
    {
        c = a%b;
        a = b;
        b = c;
    }
    return a;
}

vector<ll> primes;
set<ll> s;

void dfs(ll nod, bool chk)
{
    if(chk == 1)
        ans = min(ans, nod);
    s.insert(nod);
    for(int i = 0; i < primes.size(); ++i)
        if(nod % primes[i] == 0 && s.find(nod / primes[i]) == s.end())
            dfs(nod/primes[i], chk);
}
int main()
{

    #ifdef fisier
        ifstream f("input.in");
        ofstream g("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> k;
    if(k == 1)
    {
        cout << n;
        return 0;
    }
    ll nn = n;
    for(ll i = 2; i * i <= n; ++i)
        if(n % i == 0)
        {
            primes.pb(i);
            while(n % i == 0)
                n /= i;
        }
    if(n > 1)
        primes.pb(n);
    for(int i = 1; i <= k; ++i)
    {
        ll p;
        cin >> p;
        dfs(cmmdc(p, nn), (i == k));
    }
    cout << nn/ans;
    return 0;
}

Compilation message

sej.cpp: In function 'void dfs(ll, bool)':
sej.cpp:40:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < primes.size(); ++i)
                    ~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 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 380 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 3 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 4 ms 504 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 14 ms 376 KB Output is correct
4 Correct 9 ms 632 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 22 ms 1144 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 21 ms 988 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 504 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 122 ms 376 KB Output is correct
4 Correct 20 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 376 KB Output is correct
2 Correct 23 ms 1144 KB Output is correct
3 Correct 88 ms 508 KB Output is correct
4 Correct 21 ms 1016 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 10 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 15 ms 376 KB Output is correct
4 Correct 23 ms 1272 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 87 ms 376 KB Output is correct
4 Correct 23 ms 1144 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 68 ms 1512 KB Output is correct
2 Correct 70 ms 1632 KB Output is correct
3 Correct 99 ms 1784 KB Output is correct
4 Correct 144 ms 2756 KB Output is correct
5 Correct 93 ms 2184 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 127 ms 2584 KB Output is correct
2 Correct 451 ms 4012 KB Output is correct
3 Correct 148 ms 2680 KB Output is correct
4 Correct 149 ms 2836 KB Output is correct
5 Correct 158 ms 3404 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 154 ms 2972 KB Output is correct
2 Correct 549 ms 4792 KB Output is correct
3 Correct 189 ms 3576 KB Output is correct
4 Correct 205 ms 3868 KB Output is correct
5 Correct 192 ms 3960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 148 ms 2936 KB Output is correct
2 Correct 556 ms 4788 KB Output is correct
3 Correct 204 ms 3064 KB Output is correct
4 Correct 209 ms 3932 KB Output is correct
5 Correct 190 ms 3832 KB Output is correct