/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Accepted 15ms 4.566 MiB
#2 Wrong Answer 21ms 4.973 MiB
#3 Wrong Answer 21ms 5.047 MiB
#4 Wrong Answer 21ms 4.996 MiB
#5 Wrong Answer 20ms 5.07 MiB
#6 Wrong Answer 21ms 5.082 MiB
#7 Wrong Answer 21ms 4.988 MiB
#8 Wrong Answer 20ms 4.988 MiB
#9 Wrong Answer 26ms 5.688 MiB
#10 Wrong Answer 21ms 4.996 MiB

Code

#include<bits/stdc++.h>
#define endl        '\n'
#define F           first
#define S           second
#define pb          push_back
#define yes         cout<<"YES\n"
#define no          cout<<"NO\n"
#define all(x)      x.begin(),x.end()
#define allr(x)     x.rbegin(),x.rend()
#define error1(x)   cerr<<#x<<" = "<<(x)<<endl
#define error2(a,b) cerr<<"("<<#a<<", "<<#b<<") = ("<<(a)<<", "<<(b)<<")\n";
#define coutall(v)  for(auto &it: v) cout << it << " "; cout << endl;
using namespace std;
using ll = long long;
using ld = long double;

const int N = 1e6 + 10, Mx = 20000;
vector<int> spf(N); // SPF : smallest prime factor

void sieve() //=> O(n log(log(n)))
{
    for (int i = 1; i < N; i++) {
        spf[i] = i;
    }
    for (int i = 2; i * i < N; i++) {
        if (spf[i] == i) {
            for (int j = i * i; j < N; j += i) {
                if (spf[j] == j) spf[j] = i;
            }
        }
    }
}

void prime_factors (ll x) {
    // sieve(); // build <==
    while (x != 1) {
        cout << spf[x] << " ";
        x /= spf[x];
    }
    cout << endl;
}

vector<ll> ans;

void solve() {
    ll n;
    cin >> n;
    for(int i = 0; i < n; i++) cout << ans[i] << " \n" [i + 1 == n];
    return;
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    cin >> tc;
    sieve(); // <===
    ans.pb(6);
    ans.pb(10);
    ans.pb(15);
    ll val = 16;
    while(ans.size() < Mx) {
        while(true) {
            ll x = val;
            set<ll> st;
            while (x != 1) {
                /// cout << spf[x] << " ";
                // if(spf[x] == 2 or spf[x] == 3) {
                //     ans.pb(val);
                //     ++val;
                //     ok = 0;
                //     break;
                // }
                st.insert(spf[x]);
                x /= spf[x];
            }
            if(st.size() > 1 && (st.count(2) or st.count(3))) {
                ans.pb(val);
                ++val;
                break;
            }
            ++val;
        }
    }
    for (int t = 1; t <= tc; t++) {
        // cout << "Case " << t << ": ";
        solve();
    }
    return 0;
}

Information

Submit By
Type
Submission
Problem
P1070 Strange Sequences
Contest
Brain Booster #4
Language
C++20 (G++ 13.2.0)
Submit At
2024-07-14 17:59:52
Judged At
2024-10-03 13:35:35
Judged By
Score
10
Total Time
26ms
Peak Memory
5.688 MiB