3 条题解

  • 1
    @ 2024-8-1 16:29:36

    #include<bits/stdc++.h> using namespace std; bool check(int num) { if (num <= 1) return false; for (int i = 2; i * i <= num; ++i) { if (num % i == 0) return false; } return true; } int main() { int x; cin >> x; vector<int> primes; int sum = 0; for (int i = 2; sum + i <= x; ++i) { if (check(i)) { primes.push_back(i); sum += i; } } for (int prime : primes) { cout << prime << endl; } cout << primes.size() << endl; return 0; }

    信息

    ID
    703
    时间
    1000ms
    内存
    256MiB
    难度
    4
    标签
    递交数
    39
    已通过
    18
    上传者