# 336 条题解

• @ 2017-08-16 21:13:26
``````#py大法好
a = int(input())
b = int(input())
print(a*b)
``````
• @ 2018-02-01 21:59:45

无敌

• @ 2018-02-27 13:48:07

666

• @ 2018-05-19 20:56:02

66666666

• @ 2018-08-26 15:25:41

python 同道中人

• @ 2020-03-01 17:53:17

666

• @ 2020-03-01 17:53:27

orz

• @ 2020-03-29 23:44:11
``````print(int(input()) * int(input()) )
``````

明明这样就好了，还要写三行？

• @ 2017-10-04 17:53:44
``````#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <set>
#include <limits>
#include <string>
#include <sstream>
using namespace std;

const int oo_min=0xcfcfcfcf,oo_max=0x3f3f3f3f;

struct bigint
{
vector<int> num;
int operator == (bigint b)
{
if (num.size()!=b.num.size())
return 0;
else
{
for (unsigned long long i=0,size=num.size();i<size;i++)
if (num[i]!=b.num[i])
return 0;
return 1;
}
}
int operator != (bigint b)
{
return ((!(*this==b))?1:0);
}
int operator < (bigint b)
{
if (num.size()<b.num.size())
return 1;
else if (num.size()>b.num.size())
return 0;
else
{
for (unsigned long long i=0,size=num.size();i<size;i++)
{
if (num[size-1-i]<b.num[size-1-i])
return 1;
else if (num[size-1-i]>b.num[size-1-i])
return 0;
}
return 0;
}
}
int operator > (bigint b)
{
if (num.size()<b.num.size())
return 0;
else if (num.size()>b.num.size())
return 1;
else
{
for (unsigned long long i=0,size=num.size();i<size;i++)
{
if (num[size-1-i]<b.num[size-1-i])
return 0;
else if (num[size-1-i]>b.num[size-1-i])
return 1;
}
return 0;
}
}
int operator <= (bigint b)
{
return ((!(*this>b))?1:0);
}
int operator >= (bigint b)
{
return ((!(*this<b))?1:0);
}
bigint mov(long long x)
{
bigint ans;
ans.num.clear();
if (x+num.size()>0)
{
ans.num.resize(num.size()+x,0);
for (long long i=0,size=num.size();i<size;i++)
if (i+x>=0)
ans.num[i+x]=num[i];
}
else
ans=0;
return ans;
}
bigint operator = (long long b)
{
char s[20+1];
sprintf(s,"%lld",b);
num.clear();
num.resize(strlen(s));
for (unsigned long long i=0,size=num.size();i<size;i++)
num[i]=(s[size-1-i]-'0');
return (*this);
}
bigint operator = (string b)
{
num.clear();
num.resize(b.size());
for (unsigned long long i=0,size=num.size();i<size;i++)
num[i]=(b[size-1-i]-'0');
return (*this);
}
bigint operator + (bigint b)
{
bigint ans;
ans.num.clear();
ans.num.resize(max(num.size(),b.num.size()));
for (unsigned long long i=0,size=ans.num.size();i<size;i++)
ans.num[i]=((i<num.size())?num[i]:0)+((i<b.num.size())?b.num[i]:0);
for (unsigned long long i=0,size=ans.num.size();i<size;i++)
{
if (ans.num[i]>=10&&i==size-1)
ans.num.resize(++size);
ans.num[i+1]+=(ans.num[i]/10);
ans.num[i]%=10;
}
return ans;
}
bigint operator += (bigint b)
{
return (*this=(*this+b));
}
bigint operator - (bigint b)
{
bigint ans;
if ((*this)==b)
{
ans=0;
return ans;
}
ans.num.clear();
ans.num.resize(max(num.size(),b.num.size()));
for (unsigned long long i=0,size=ans.num.size();i<size;i++)
ans.num[i]=((i<num.size())?num[i]:0)-((i<b.num.size())?b.num[i]:0);
for (unsigned long long i=0,size=ans.num.size();i<size;i++)
while (ans.num[i]<0)
ans.num[i]+=10,ans.num[i+1]--;
while (ans.num[ans.num.size()-1]==0)
ans.num.resize(ans.num.size()-1);
return ans;
}
bigint operator -= (bigint b)
{
return (*this=(*this-b));
}
bigint operator * (bigint b)
{
bigint ans,num_0;
num_0=0;
ans.num.clear();
if (*this!=num_0&&b!=num_0)
{
ans.num.resize(num.size()+b.num.size()-1);
for (unsigned long long i=0,size_1=num.size();i<size_1;i++)
for (unsigned long long j=0,size_2=b.num.size();j<size_2;j++)
ans.num[i+j]+=(num[i]*b.num[j]);
for (unsigned long long i=0,size=ans.num.size();i<size;i++)
{
if (ans.num[i]>=10&&i==size-1)
ans.num.resize(++size);
ans.num[i+1]+=(ans.num[i]/10);
ans.num[i]%=10;
}
}
else
ans=0;
return ans;
}
bigint operator *= (bigint b)
{
return (*this=(*this*b));
}
bigint operator / (bigint b)
{
bigint ans,num_0;
num_0=0;
if (*this<b)
return num_0;
if (*this!=num_0&&*this>num_0)
{
bigint x,y;
x=*this,y=b.mov(num.size()-b.num.size());
ans.num.resize(num.size()-b.num.size()+1,0);
for (long long i=ans.num.size()-1;i>=0;i--,y=y.mov(-1))
while (x>=y)
x-=y,ans.num[i]++;
for (unsigned long long i=0,size=ans.num.size();i<size;i++)
{
if (ans.num[i]>=10&&i==size-1)
ans.num.resize(++size);
ans.num[i+1]+=(ans.num[i]/10);
ans.num[i]%=10;
}
while (ans.num.size()>1&&ans.num[ans.num.size()-1]==0)
ans.num.resize(ans.num.size()-1);
}
else
ans=0;
return ans;
}
bigint operator /= (bigint b)
{
return (*this=(*this/b));
}
void print()
{
for (unsigned long long i=0,size=num.size();i<size;i++)
printf("%d",num[size-1-i]);
}
};

char s[10000+1];
#define s(x) s[x-1]
bigint a,b,c;
string s_a,s_b;
#define s_a(x) s_a[x-1]
#define s_b(x) s_b[x-1]

int main()
{
while (~scanf("%s",s))
{
s_a=s;
getchar();
scanf("%s",s);
s_b=s;
getchar();
a=s_a,b=s_b;
c=a*b;
c.print();
printf("\n");
}
}
``````
• @ 2017-10-04 17:54:12

很H2O的題

• @ 2017-12-28 09:39:59

DALAO

• @ 2018-11-09 21:49:47

@sky1231: 大整数类？

• @ 2024-06-17 19:22:57

Java和Python都支持处理大数，就是对C++ OIer不太友好

Java AC code

``````import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[])
{
Scanner cin=new Scanner(System.in);
BigInteger a=cin.nextBigInteger();
BigInteger b=cin.nextBigInteger();
System.out.print(a.multiply(b));
}
}
``````

Python AC code

``````print(int(input())*int(input()))
``````

只有用C++AC的才有实力

• @ 2022-05-22 19:42:37

python的巅峰时刻:

``````n=int(input())
m=int(input())
print(x*y)

``````
• @ 2022-05-10 12:55:52

a = int(input())

b = int(input())

print(a*b)

• @ 2022-05-10 12:54:57

d = int(input())
f = int(input())
print(d*f)
//ha,ha,用c++的手都要残了

• @ 2021-09-27 17:14:33

py 无敌！自带高精度！

``````a = int(input())
b = int(input())
print(a*b)
``````
• @ 2020-12-31 00:51:52
``````#include<bits/stdc++.h>
#define ll long long int
using namespace std;
struct bigint{
int a[7000],n,N=1000,t=3;
bigint (){
memset(a,0,sizeof(a));
}
bigint(char* s,int _n){
memset(a,0,sizeof(a));
char* _end=s+_n,*beg;
int p=0;
while(_end-t>s){
beg=_end-t;
for(int i=0;i<t;i++){
a[p]*=10;
a[p]+=beg[i]-'0';
}
++p;
_end=beg;
}
if(_end>s){
for(int i=0;i<_end-s;i++){
a[p]*=10;
a[p]+=s[i]-'0';
}
++p;
}
n=p;
}
int& operator [](int i){
return a[i];
}
bigint operator * (bigint& b){
int i,j,m=b.n;
bigint r;
int sr=n+m-1;
for(i=0;i<n;++i)
for(j=0;j<m;++j)
r[i+j]+=a[i]*b[j];
for(i=0;i<sr;++i){
r[i+1]+=r[i]/N;
r[i]%=N;
}
if(r[sr])sr++;
r.n=sr;
return r;
}
void show(){
int i=n-2;
printf("%d",a[n-1]);
while(i>=0)
printf("%03d",a[i--]);
}
};

char s[10001];
int main() {
//freopen("in.txt","r",stdin);
scanf("%s",s);
bigint a(s,strlen(s));
scanf("%s",s);
bigint b(s,strlen(s));
(a*b).show();
}

``````

后两个wa了的，可能是中间爆int了，压四位先乘了再进位会爆int...要不用longlong 要不就压三位

• @ 2020-07-12 17:19:02

#include<iostream>
#include<string>
using namespace std;
const int N = 10001;
void h_multiply_2(int a[], int b[], int c[])
{
int la = a[0];
int lb = b[0];
for(int i=1;i<=la;i++)
{
for(int j=1;j<=lb;j++)
{
c[i+j-1] += a[i] * b[j];
}
}
for(int i=1;i<=la+lb;i++)
{
c[i+1] += c[i] / 10;
c[i] %= 10;
}
c[0] = la+lb;
}
int convert(string s,int n[])
{
int length = s.length();
for(int i=1;i<=length;i++)
{
n[i] = s[length-i] - '0';
}
n[0] = length;
return length;
}
void output(int n[])//n是算好了的高精度数
{
int length = n[0];
if(length==0)
{
cout << 0 << endl;
return;
}
for(int i=length;i>=1;i--)
{
cout << n[i];
}
cout << endl;
}
int trim(int n[])
{
int length = 0;
for(int i=n[0];i>0;i--)
{
if(n[i]!=0)
{
length = i;
break;
}
}
n[0] = length;
return length;
}
int a[N+1];
int b[N+1];
int c2[2*N+1];
int main()
{
string s1, s2;
cin >> s1 >> s2;
convert(s1, a);
convert(s2, b);
h_multiply_2(a,b,c2);
trim(c2);
output(c2);
return 0；
}

• @ 2020-07-12 14:05:39
``````x=int(input())
y=int(input())
print(x*y)
``````

真香！！

• @ 2018-11-09 21:48:53

告诉你什么叫做流！弊！
Python3三行代码解决：

``````x=int(input()) #input()用于读入一行字符，int()用于把字串转为数字
y=int(input());#在python中分号可以省略，也可以加上
print(x*y)     #输出a*b，python中有乘方运算符（^）
``````

哇哈哈哈哈哈哈哈哈哈哈哈哈~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//笑出猪叫

• @ 2020-05-26 14:48:13

明明一行就行

• @ 2022-08-23 09:44:45

兄弟，Python中的 ^ 符号不是乘方而是 异或

• @ 2018-09-12 16:50:14

``````main = do { a<-readLn; b<-readLn; print (a*b) }
``````
• @ 2018-07-04 00:00:44

#include <iostream>
#include <cstring>
using namespace std;
int a[10601],b[10601],c[20601];
int main(int argc, char** argv)
{
int la,lb,x=0,o;
string A,B;
cin>>A>>B;
la=A.length();
lb=B.length();
for(int i=1;i<=la;i++)
{
a[i]=A[la-i]-'0';
}
for(int j=1;j<=lb;j++)
{
b[j]=B[lb-j]-'0';
}
for(int k=1;k<=la;k++)
{
for(int l=1;l<=lb;l++)
{
c[k+l-1]=a[k]*b[l]+c[k+l-1]+x;
x=c[k+l-1]/10;
c[k+l-1]=c[k+l-1]%10;
}
c[k+lb]=x;
x=0;
}
o=la+lb;
while(c[o]==0&&o!=0)
{
o--;
}
for(int oo=o;oo>=1;oo--)
{
cout<<c[oo];
}
return 0;
}

• @ 2018-06-01 17:26:55

golang大法
```go

packagepa main

import (
"fmt"
"math/big"
)

func main() {

var stra, strb string

fmt.Scanf("%s\n%s", &stra, &strb)

a := big.NewInt(0)
b := big.NewInt(0)
ans := big.NewInt(0)

a.SetString(stra, 10)
b.SetString(strb, 10)

ans.Mul(a, b)

fmt.Println(ans)
}

• @ 2018-06-01 17:03:36
``````#include<bits/stdc++.h>
using namespace std;
int main(){
char st1[10005],st2[10005];
int a[10005],b[10005],c[20005];
int i,j,len1,len2;
cin >> st1 >> st2;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
len1=strlen(st1);
len2=strlen(st2);
j=1;
for (i=len1-1;i>=0;i--)
{
a[j++]=st1[i]-'0';
}
j=1;
for (i=len2-1;i>=0;i--)
{
b[j++]=st2[i]-'0';
}

for (i=1;i<=len1;i++)
for (j=1;j<=len2;j++)
c[i+j-1]+=a[i]*b[j];

for(i=1;i<len1+len2;i++){
c[i+1]+=c[i]/10;
c[i]%=10;
}
while (!c[i] && i>1){
i--;
}
while (i){
printf("%d",c[i--]);
}
printf("\n");
return 0;
}

``````

在网上淘得代码，确实是很不错，模拟你现实用笔算的过程，在计算机中模拟出来，真心给个赞。

• @ 2018-05-22 15:25:13

#include<bits/stdc++.h>
using namespace std;
int main()
{
char a1[30000],a2[30000];
int a[30000],b[30000],c[30000],la,lb,lc,i,j,x;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
cin>>a1>>a2;
la=strlen(a1);
lb=strlen(a2);
for(i=0;i<=la-1;i++) a[la-i]=a1[i]-48;
for(i=0;i<=lb-1;i++) b[lb-i]=a2[i]-48;
for(i=1;i<=la;i++)
{
x=0;
for(j=1;j<=lb;j++)
{
c[i+j-1]=a[i]*b[j]+x+c[i+j-1];
x=c[i+j-1]/10;
c[i+j-1]%=10;
}
c[i+lb]=x;
}
lc=la+lb;
while(c[lc]==0&&lc>1)
lc--;
for(i=lc;i>=1;i--)
cout<<c[i];
cout<<endl;
}

• @ 2018-05-22 15:24:30

#include<bits/stdc++.h>
using namespace std;
int main()
{
char a1[30000],a2[30000];
int a[30000],b[30000],c[30000],la,lb,lc,i,j,x;
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
cin>>a1>>a2;
la=strlen(a1);
lb=strlen(a2);
for(i=0;i<=la-1;i++) a[la-i]=a1[i]-48;
for(i=0;i<=lb-1;i++) b[lb-i]=a2[i]-48;
for(i=1;i<=la;i++)
{
x=0;
for(j=1;j<=lb;j++)
{
c[i+j-1]=a[i]*b[j]+x+c[i+j-1];
x=c[i+j-1]/10;
c[i+j-1]%=10;
}
c[i+lb]=x;
}
lc=la+lb;
while(c[lc]==0&&lc>1)
lc--;
for(i=lc;i>=1;i--)
cout<<c[i];
cout<<endl;
}

• @ 2018-04-07 09:43:39

Java大法好

``````import java.math.BigInteger;
import java.util.Scanner;

public class Main
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
BigInteger A = in.nextBigInteger(), B = in.nextBigInteger();
System.out.println(A.multiply(B));
in.close();
}
}
``````
• @ 2018-03-27 17:27:38

print(int(input())int(input()))

• @ 2018-03-27 17:26:40
``````print(int(input())*int(input()))

``````

ID
1040

7

(无)

16537

3167

19%

26