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

WA,为什么啊,真的和读入有关吗?

Posted by blackwing at 2007-11-30 00:05:18 on Problem 2389
#include <iostream>
#include <string>
using namespace std;

int main()
{
    string a,b;
    int lena,lenb,lenc;
    int c[100]={0};
    cin>>a>>b;
    lena=a.size();
    lenb=b.size();
    for(int i=0;i<lena;++i)
    {
        for(int j=0;j<lenb;++j)
        {
            c[i+j]+=(a[i]-48)*(b[j]-48);
            c[i+j+1]+=c[i+j]/10;
            c[i+j]%=10;
        }
    }
        
    c[lena+lenb-1]==0?lenc=lena+lenb-1:lenc=lena+lenb;
    for(int m=lenc-1;m>=0;--m)cout<<c[m];
}
    

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