|
|
|
|
讨论 Discussion |
|
| |
少于牛鼻 |
#include <bits/stdc++.h>
using namespace std;
int main(){
freopen("p1256.in","r",stdin);
freopen("p1256.out","w",stdout);
string sa,sb,t; char s[6];
int a[10001]={0},b[10001]={0},c[21001]={0};
getline(cin,sa);
getline(cin,sb);
int x,y,z,i,j,k;
x=sa.length();y=sb.length();
x=0;
while(sa.length()>2){
t=sa.substr(sa.length()-3,3);
a[++x]=atoi(t.c_str());
sa.erase(sa.length()-3,3);
}
if (sa.length()>0) a[++x]=atoi(sa.c_str());
y=0;
while(sb.length()>2){
t=sb.substr(sb.length()-3,3);
b[++y]=atoi(t.c_str());
sb.erase(sb.length()-3,3);
}
if (sb.length()>0)b[++y]=atoi(sb.c_str());
for(i=1;i<=x;i++)
for(j=1;j<=y;j++)
{
c[i+j-1]+=a[i]*b[j];
c[i+j]+=c[i+j-1]/1000;
c[i+j-1]%=1000;
}
for(int m=x+y+1;m>=0;m--){
if(c[m]>0){k=m;break;}
}
for(i=k;i>=1;i--){
sprintf(s,"%d",c[i]);
if(i!=k) for(int x=1;x<=3-strlen(s);x++)cout<<0;
cout<<c[i];
}
fclose(stdin);
fclose(stdout);
return 0;
}
( ) |
|
|
|
|
|
|
|
|
|
Flag |
|
题号 |
P1256 |
|
其它 |
通过 |
45人 |
提交 |
221次 |
通过率 |
20% |
难度 |
3 |
|
|
|
|
|
|