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

大牛们帮忙看看为什么错了,测试数据都是对的,而且没有讨论区中所说的问题

Posted by lcj0227 at 2007-08-04 23:40:23 on Problem 1060
#include<iostream.h>
#include<string.h>
int fab(int a)
{
    if(a>=0) return a;
    if(a<0)  return -a;
}
int main()
{
    int a[1001],b[1001],c[1001],*r,n,i,j,flag,left,x,y,z,lcj;
    cin>>n;
    while(n--)
    {
        cin>>x;
        for(i=x-1;i>=0;i--)
           cin>>a[i];
        cin>>y;
        for(i=y-1;i>=0;i--)
           cin>>b[i];
        cin>>z;
        for(i=z-1;i>=0;i--)
           cin>>c[i];
        r=new int[x+y-1];
        memset(r,0,sizeof(r));
        for(i=0;i<x;i++)
           for(j=0;j<y;j++)
           {
               r[i+j]+=a[i]*b[j];
           }
        for(i=0;i<=x+y-2;i++)
           r[i]=fab(r[i])%2;     
        flag=x+y-2;
        while(flag>=(z-1))
        {
            left=flag-z+1;
            for(i=0;i<z;i++)
              r[i+left]=r[i+left]-c[i];
            lcj=0;
            for(i=x+y-2;i>=0;i--)
              {r[i]=fab(r[i]);
                  if(r[i]!=0&&lcj==0) {flag=i; lcj=1;}
              }     
        }
        for(i=0;i<=x+y-2;i++)
           r[i]=fab(r[i])%2;
        cout<<flag+1<<" "<<r[flag];
        for(i=flag-1;i>=0;i--)
         cout<<" "<<r[i];
        cout<<endl;
    }
    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