/ SeriousOJ /

Record Detail

Runtime Error


  
# Status Time Cost Memory Cost
#1 Accepted 2ms 540.0 KiB
#2 Runtime Error foo: foo.cc:14: void solve(): Assertion `a[i] > 0' failed. 2ms 796.0 KiB
#3 Runtime Error foo: foo.cc:14: void solve(): Assertion `a[i] > 0' failed. 2ms 540.0 KiB

Code

#include <bits/stdc++.h>

using namespace std;

// #include "debug.h"

void solve() {
        int n;
        cin >> n;

        vector<int> a(n);
        for (int i = 0; i < n; ++i) {
                cin >> a[i];
                assert(a[i] > 0);
        }

        vector<int> ans(n + 1, 1);
        for (int i = 1; i <= 1e5; ++i) {
                int cnt = 0;

                for (int j = 0; j < n; ++j) {
                        cnt += (a[j] % i == 0);
                }

                for (int j = 1; j <= cnt; ++j) {
                        ans[j] = i;
                }
        }

        for (int i = 1; i <= n; ++i) {
                cout << ans[i] << ' ';
        }
        cout << '\n';
}

int32_t main() {
        ios_base::sync_with_stdio(false);
        cin.tie(0);

        int tc = 1;

        while (tc--) {
                solve();
        }
}

Information

Submit By
Type
Submission
Problem
P1151 Max gcd group
Contest
Happy New Year 2025
Language
C++11 (G++ 13.2.0)
Submit At
2025-01-02 16:19:25
Judged At
2025-01-02 16:19:25
Judged By
Score
0
Total Time
2ms
Peak Memory
796.0 KiB