#include <iostream>
#include <cmath>
#include <cstring>
using namespace std;
bool mark[1000000005];
int n, s, e;
void xxs()
{
if (s == 1)
s += 1;
for (int i = 2; i <= e; i++)
{
if (!mark[i])
{
for (int j = i * i; j <= e; j += i)
mark[j] = 1;
}
}
for (int i = s; i <= e; i++)
if (!mark[i])
cout << i << " ";
}
int main()
{
// for (int i = 2; i <= 1000000005; i++)
// mark[i] = 1;
cin >> n;
while (n--)
{
cin >> s >> e;
memset(mark, false, sizeof(mark));
xxs();
cout << endl;
}
return 0;
}
大佬看看這個WA的代碼,(Wonderful Answer)
uj5u.com熱心網友回復:
沒有題目,何來錯誤答案?uj5u.com熱心網友回復:
你這哪是動態陣列?而且你要達到什么目的需求也沒說清楚,你這是要找出質數嗎?
uj5u.com熱心網友回復:
從洛谷帖子直接復制過來,忘了
UVA10474 大理石在哪兒 Where is the Marble?
題意翻譯
現有N個大理石,每個大理石上寫了一個非負整數。首先把各數從小到大排序,然后回 答Q個問題。每個問題問是否有一個大理石寫著某個整數x,如果是,還要回答哪個大理石上 寫著x。排序后的大理石從左到右編號為1~N。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/259067.html
標籤:C++ 語言
上一篇:c++
下一篇:fgets函式使用
