답안 #197370

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197370 2020-01-20T15:13:19 Z stefdasca Strongbox (POI11_sej) C++14
70 / 100
1000 ms 2424 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;


int add(int a, int b)
{
    ll x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
ll mul(ll a, ll b)
{
    return (a*b) % mod;
}

ll pw(ll a, ll b)
{
    ll ans = 1;
    while(b)
    {
        if(b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
long long rand_seed()
{
    long long a = rng();
    return a;
}
ll n, k, vv[250002];

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

bool tri(ll divi)
{
    for(int i = 1; i < k; ++i)
        if(vv[i] % divi == 0)
            return 0;
    return 1;
}
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;
    for(int i = 1; i <= k; ++i)
        cin >> vv[i];
    if(k == 1)
    {
        cout << n;
        return 0;
    }
    ll nr = cmmdc(vv[k], n);
    ll ans = 1;
    for(ll i = 1; i * i <= nr; ++i)
        if(nr % i == 0)
        {
            if(n / i > ans && tri(i))
                ans = max(ans, n / i);
            if(n / (nr / i) > ans && tri(nr / i))
                ans = max(ans, n / (nr / i));
        }
    cout << ans;
    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 380 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 6 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 14 ms 376 KB Output is correct
4 Correct 31 ms 376 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 2 ms 376 KB Output is correct
4 Correct 144 ms 400 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 31 ms 380 KB Output is correct
2 Correct 4 ms 376 KB Output is correct
3 Correct 125 ms 408 KB Output is correct
4 Correct 119 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 99 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 154 ms 428 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 3 ms 376 KB Output is correct
4 Correct 162 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 7 ms 376 KB Output is correct
3 Correct 89 ms 376 KB Output is correct
4 Correct 178 ms 376 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 122 ms 1172 KB Output is correct
2 Correct 327 ms 1188 KB Output is correct
3 Execution timed out 1086 ms 1144 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 78 ms 1912 KB Output is correct
2 Correct 48 ms 1844 KB Output is correct
3 Execution timed out 1064 ms 1912 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 79 ms 2336 KB Output is correct
2 Correct 59 ms 2344 KB Output is correct
3 Execution timed out 1034 ms 2268 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 86 ms 2424 KB Output is correct
2 Correct 60 ms 2288 KB Output is correct
3 Execution timed out 1037 ms 2300 KB Time limit exceeded
4 Halted 0 ms 0 KB -