| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:请各位帮忙看下,出现output limit exceed 问题In Reply To:请各位帮忙看下,出现output limit exceed 问题 Posted by:gzxx102lsm at 2008-03-17 00:00:34 > #include<iostream>
> #include<math.h>
> using namespace std;
> int main()
> {
> int i,j,k,p,m,n,c,a[1101];
> while(1)
> {
> scanf("%d %d",&n,&c);
> a[0]=1;j=1;
> for(m=2;m<=n;m++)
> {
> k=sqrt(m);
> for(i=2;i<=k;i++)
> if(m%i==0)break;
> if(i>=k+1)
> {
> a[j]=m;
> j++;
> p=j;
> }
> }
> if(c>=p)
> {
> printf("%d %d:",n,c);
> for(i=0;i<p;i++)
> printf(" %d",a[i]);
> printf("\n\n");
> }
> else
> {
> if(p%2==0)
> {
> printf("%d %d:",n,c);
> for(i=p/2-c;i<=p/2+c-1;i++)
> printf(" %d",a[i]);
> printf("\n\n");
> }
> else
> {
> printf("%d %d:",n,c);
> for(i=p/2-(2*c-1)/2;i<=p/2+(2*c-1)/2;i++)
> printf(" %d",a[i]);
> printf("\n\n");
> }
> }
> }
> return 0;
> }
while(scanf("%d %d", &n, &c) != EOF)
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator