找回密码
 注册
搜索
热搜: 回贴
  • 前程无忧官网首页 有什么好的平台可以
  • 最新的销售平台 互联网营销的平台有哪
  • 制作网页的基本流程 网页制作和网页设
  • 【帝国CMS】输出带序号的列表(数字排
  • 网站建设公司 三一,中联,极东泵车的
  • 织梦 建站 织梦网站模版后台怎么更改
  • 云服务官网 哪些网站有免费的简历模板
  • 如何建网站要什么条件 建网站要用什么
  • 吉林市移动公司电话 吉林省退休人员网
  • 设计类毕业论文 网站设计与实现毕业论
查看: 550|回复: 0

[求助]奇怪的问题,究竟是哪儿不对.

[复制链接]
发表于 2009-11-3 00:53:37 | 显示全部楼层 |阅读模式 IP:江苏扬州
//找在10000内的质素里等差最大的等差数列 如3 5 7差为2
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main(int argc, char* argv[])
{
const int SIZE = 10000;
int num[SIZE+1]; //一个栅栏,即num[0];
num[0]=0;
num[1]=0;
for(int m=2;m<=SIZE;m++) //set all the num 1
num[m]=1;
int pp=sqrt(SIZE)+1;
for (int a=2;a!=pp;a++)
for(int b=2;b<=sqrt(a);b++) //find the prime number in sqrt(SIZE) and set others 0
if(a%b==0)
{
num[a]=0;
break;
}
for(int i=1;i!=pp;i++) // find tne prime number in SIZE and set them 1
{
if(num[i]==0)
continue;

for (int j=2;j<=SIZE / i;j++)
num[i*j]=0;
}
vector<int> PN;

for(int n=1;n<SIZE;n++) //save the prime number in vector PN
if(num[n]==1)
PN.push_back(n);
vector<int>::iterator Pb=PN.begin();
vector<int>::reverse_iterator Pe=PN.rbegin();
int aa[4]={1,1,1,1};
vector<int> L(aa,aa+4);
int abc=PN.size()/2;

for (int N=0;N < abc;N++,Pb++)
{
for (int M=0;M < abc;M++,Pe++)
{

L[3]=(*Pb+*Pe)/2;
if(f
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|小黑屋|最新主题|手机版|微赢网络技术论坛 ( 苏ICP备08020429号 )

GMT+8, 2024-9-30 05:26 , Processed in 0.173549 second(s), 13 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表