QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#188263#1095. Brilliant Sequence of UmbrellasAs3b_team_f_masr#WA 6ms12756kbC++14970b2023-09-25 17:52:402023-09-25 17:52:41

Judging History

你现在查看的是最新测评结果

  • [2023-09-25 17:52:41]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:12756kb
  • [2023-09-25 17:52:40]
  • 提交

answer

#include <bits/stdc++.h>

typedef long double ld;
typedef long long ll;
using namespace std;
int di[] = {1, 0, -1, 0, 0, 1, -1, 1};
int dj[] = {0, 1, 0, -1, -1, 0, 1, -1};

const ll oo = 1e18;
const int N = 2e6 + 5, M = 1e4 + 5, MOD = 1e9 + 7;
#define EPS 1e-9

ll n, q, a[N];
bool p[N];
vector<int>primes;
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    //memset(dp, -1, sizeof dp);
    ll n;
    cin>>n;
    primes.push_back(1);
    primes.push_back(1);
    for(ll i=2;i<N;i++)
    {
        if(!p[N])
        {
            primes.push_back(i);
            for(ll j=i*i;j<N;j+=i)
            {
                p[i]=1;
            }
        }

    }
    vector<ll>ans;
    for(int i=0;i<primes.size();i++)
    {
        if(1ll*primes[i]*primes[i+1]<=n)ans.push_back(1ll*primes[i]*primes[i+1]);
        else break;
    }
    cout<<ans.size()<<'\n';
    for(auto x:ans)cout<<x<<" ";
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 6ms
memory: 12756kb

input:

10

output:

3
1 2 6 

result:

ok OK.

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 12304kb

input:

22

output:

5
1 2 6 12 20 

result:

wrong answer GCD's are not sorted in increasing order!