Информатика и математика

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » Информатика и математика » Байт решений задач с acm.pku » acm.pku 1060 Modular multiplication of polynomials


acm.pku 1060 Modular multiplication of polynomials

Сообщений 1 страница 6 из 6

1

http://acm.pku.edu.cn/JudgeOnline/problem?id=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;
}

0

2

Are Online Virus Scan such as Housecall and OneCare Safety scanner just as effective to their Manual antivirus scan counterparts? Can you also give me some good Online Scanners? Thanks for the most informative answer! 10 points for the best! 

_____________
wow guide

0

3

When i view online streaming video, or when browse myspace or yahoo chat...I checked the cpu temp and they are all fine, I ran a virus check, nothing showed, I have a fan blowing into the computer as well....any ideas?? its driving me nuts..........

_________________
download xbox 360 games

0

4

i have kaspersky virus protection 2010 and under "my protection" it says it has detected 20 trojans. I did a full scan which took about 2 and a half hours, and nothing happened. it still says i have 20 trojans. What do i do to get rid of them? 

_____________
cheap xbox 360 games

0

5

It seems avira can't open and scan the files containing the virus, ive tried spybot, but it only removes spyware and not the virus itself. Its causing the my computer to run extremely slow, its always oprating on 100 percent even if im not doing anything, any tips on how to remove it? thanks in advance

_________________
download xbox 360 games

0

6

The doctor diagnosed remotely is not intended or cure - usually call for a doctor to the house...
  :offtop:

0


Вы здесь » Информатика и математика » Байт решений задач с acm.pku » acm.pku 1060 Modular multiplication of polynomials