100 Accepted

# 状态 分数 耗时 内存占用
#1 Accepted 10 1ms 7.5 MiB
#2 Accepted 10 1ms 7.7 MiB
#3 Accepted 10 1ms 6.8 MiB
#4 Accepted 10 1ms 6.7 MiB
#5 Accepted 10 2ms 6.8 MiB
#6 Accepted 10 1ms 6.7 MiB
#7 Accepted 10 0ms 7.6 MiB
#8 Accepted 10 1ms 6.8 MiB
#9 Accepted 10 0ms 6.8 MiB
#10 Accepted 10 1ms 6.9 MiB

代码

#include <bits/stdc++.h>
using namespace std;
int a [5005], m, n;
int main()
{
    // 1: 1 2 3 ....
    // 2: 2 4 6 ....
    // 3: 3 6 9
    cin >> n >> m;
    for (int i = 1; i <= m; i++)
    {
        for (int j = i; j <= n; j += i)
        {
            if (a[j] == 0) a[j] = 1;
            else a[j] = 0;
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (a[i] == 0) cout << i << " ";
    }
    return 0;
}

信息

递交者
题目
DJKS1015  硬币翻转
比赛
2024年3月等考一级题单
语言
C++ 98
递交时间
1 年前
评测时间
1 年前
分数
100
总耗时
8ms
峰值内存
7.7 MiB