Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:我0ms,212k,敢问8k怎么编的?

Posted by zoujinyong at 2013-11-10 22:17:11 on Problem 2739
In Reply To:我0ms,212k,敢问8k怎么编的? Posted by:wzf990404 at 2013-05-11 16:49:40
> #include<stdio.h>
> #include<iostream>
> using namespace std;
> int sum[2001],t,n,p[10001],ans;
> int main()
> {int i,j;
>  for(i=2;i<=10000;i++)
>   if(p[i]==0)
>    for(j=i*i;j<=10000;j+=i)
>     p[j]=1;
>  for(i=2;i<=10000;i++)
>   if(p[i]==0)
>   {t++;
>    sum[t]=sum[t-1]+i;
>   }
>  while(scanf("%d",&n)&&n!=0)
>  {ans=0;i=1;j=0;
>   while(i>j)
>   {if(sum[i]-sum[j]==n) ans++;
>    i++;
>    while(sum[i]-sum[j]>n) j++;
>   }
>   printf("%d\n",ans);
>  }
>  return 0;
> }

空间是动态开辟的

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator