/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 320.0 KiB
#2 Wrong Answer 2ms 532.0 KiB
#3 Wrong Answer 4ms 532.0 KiB
#4 Wrong Answer 4ms 532.0 KiB
#5 Wrong Answer 5ms 532.0 KiB
#6 Wrong Answer 5ms 532.0 KiB
#7 Wrong Answer 8ms 532.0 KiB
#8 Wrong Answer 12ms 560.0 KiB
#9 Wrong Answer 12ms 532.0 KiB
#10 Wrong Answer 13ms 532.0 KiB
#11 Accepted 16ms 532.0 KiB
#12 Wrong Answer 15ms 324.0 KiB
#13 Wrong Answer 13ms 532.0 KiB
#14 Wrong Answer 12ms 324.0 KiB
#15 Wrong Answer 7ms 532.0 KiB
#16 Wrong Answer 8ms 532.0 KiB
#17 Wrong Answer 10ms 320.0 KiB
#18 Wrong Answer 10ms 532.0 KiB
#19 Wrong Answer 12ms 484.0 KiB

Code

#include <bits/stdc++.h>

#ifdef LOCAL
#include "template.cpp.h"
#else
#define debug(...)
#endif

#define int long long
using namespace std;
#define cinv(v) for (auto &it:v) cin>>it;
#define coutv(v) for (auto &it:v) cout<< it<<' '; cout<<'\n';

const int N = 105;
int cnt[N];

void shelby() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int x;
        cin >> x;
        for (int j = 1; j * j <= x; ++j) {
            if (x % j == 0) {
                cnt[j]++;
                if (j != x / j) cnt[x / j]++;
            }
        }
    }
    int ans = 0;
    for (int i = 1; i < N; ++i) {
        for (int j = 1; j < N; ++j) {
            if (i == j) {
                if (cnt[i] == n) ans = max(ans, 2 * i);
                continue;
            }
            int a = cnt[i], b = cnt[j], c = (i * j < N ? cnt[i * j] : 0);
            if (a < b) swap(a, b);
            int extra = a - n / 2 - (n % 2);
            c -= extra;
            if (extra < 0 || c < 0) continue;
            b -= c;
            if (b == n / 2) ans = max(ans, i + j);
        }
    }
    cout << ans << '\n';
    for (int i = 1; i < N; ++i) cnt[i] = 0;
}

signed main() {
    cin.tie(0)->ios_base::sync_with_stdio(0);
    int t = 1;
    cin >> t;
    for (int _ = 1; _ <= t; ++_) {
//        cout << "Case " << _ << ": ";
        shelby();
    }
}

Information

Submit By
Type
Submission
Problem
P1076 Even Odd GCD (Easy Version)
Language
C++20 (G++ 13.2.0)
Submit At
2024-08-16 22:08:40
Judged At
2024-08-16 22:08:40
Judged By
Score
11
Total Time
16ms
Peak Memory
560.0 KiB