| ||||||||||
| 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 | |||||||||
不知道哪里有bug/*
Name: 2726 Holiday Hotel
Copyright:
Author: Blueblood
Date:
Description:
*/
#include <iostream>
#include <string>
using namespace std;
int main()
{
int a[41],b[41], c[82];
int i,j;
string s;
cin >> s;
for (i = 0; i < s.length(); i++)
a[i] = s[s.length() -1 - i] - '0';
for (; i < 41; i++)
a[i] = 0;
cin >> s;
for (i = 0; i < s.length(); i++)
b[i] = s[s.length() - 1 - i] - '0';
for (; i < 41; i++)
b[i] = 0;
for (i = 0; i < 82; i++)
c[i] = 0;
for (i = 0; i < 41; i++)
{
int carry = 0;
int tmp[82];
for (j = 0; j < 41; j++)
{
tmp[j] = a[i] * b[j] + carry;
if ( tmp[j] >= 10)
{
carry = tmp[j] /10;
tmp[j] = tmp[j] % 10;
}
else
{
carry = 0;
}
}
tmp[41] = carry;
for (j = 42; j < 82; j++)
tmp[j] = 0;
carry = 0;
for (j = 0; j < 82; j++)
{
c[j+i] += tmp[j] + carry;
if (c[i+j] >= 10)
{
carry = 1;
c[i+j] -= 10;
}
else
{
carry = 0;
}
}
}
i = 81;
while (i >= 0 && c[i] == 0)
i--;
if ( i < 0)
cout << 0 ;
else
for (; i >= 0; i--)
cout << c[i];
cout << endl;
system("pause");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator