/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 2ms 328.0 KiB
#2 Wrong Answer 67ms 1.422 MiB

Code

#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

bool is_prime(int x) {
    if (x <= 1) return false;
    if (x <= 3) return true;
    if (x % 2 == 0 || x % 3 == 0) return false;
    int i = 5;
    while (i * i <= x) {
        if (x % i == 0 || x % (i + 2) == 0) return false;
        i += 6;
    }
    return true;
}

vector<int> generate_prime_array(int n) {
    vector<int> primes;
    int num = 2;
    while (primes.size() < n) {
        if (is_prime(num)) {
            primes.push_back(num);
        }
        num++;
    }
    return primes;
}

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

int main()
{
    optimize();
    ll t;
    cin >> t;
    while(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:13:37
Judged At
2024-11-11 03:23:07
Judged By
Score
0
Total Time
67ms
Peak Memory
1.422 MiB