QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499380#6728. To the ParkUmokWA 0ms3484kbC++201.2kb2024-07-31 13:34:542024-07-31 13:34:54

Judging History

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

  • [2024-07-31 13:34:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3484kb
  • [2024-07-31 13:34:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e5 + 5;
#define int long long
#define MAX LONG_LONG_MAX
int ar[N];
void solve()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n + 1; i++)
        ar[i] = 0;
    queue<int> q;

    for (int i = 2; i <= n - 1; i++)
    {
        if (i % 2)
        {
            for (int j = 2; j * i <= n; j++)
            {
                if (ar[i * j])
                    continue;
                q.push(i);
                q.push(i * j);
            }
        }
        else
        {
            if (ar[i])
                continue;
            int j = i;
            for (j = i + 2; j <= n; j += 2)
                if (ar[j])
                    continue;
            if (j > n)
                continue;
            ar[i] = ar[j] = 1;
            q.push(i);
            q.push(j);
        }
    }
    cout << q.size() / 2 << " ";
    while (!q.empty())
    {
        cout << q.front() << " ";
        q.pop();
    }
    cout << endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int tcase;
    cin >> tcase;

    while (tcase--)
        solve();

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3484kb

input:

3
1
4
6

output:

0 
0 
1 3 6 

result:

wrong answer Case #2: Participant has a worse answer