错误
  • 板块P1303 A*B Problem
  • 楼主hanran_
  • 当前回复1
  • 已保存回复1
  • 发布时间2021/7/6 08:57
  • 上次更新2023/11/4 18:34:09
查看原帖
错误
260361
hanran_楼主2021/7/6 08:57


#include <iostream>

using namespace std;

string x,y;
int a[100001],b[100001],c[100001],la,lb,lc;

int main () {
	cin >> x >> y;
	la = x.length();
	lb = y.length();
	for (int i = 0; i < la; i++) {
		a[la - i - 1] = x[i] - '0';
	}
	for (int i = 0; i < lb; i++) {
		b[lb - i - 1] = y[i] - '0';
	}
	
//	for (int i = 0; i < la; i++) {
//		cout << a[i];
//	}
	for (int j = 0; j < lb; j++) {
		for (int i = 0; i < la; i++) {
			c[i + j] += a[i] * b[j];
			c[i + j + 1] +=(c[i + j] / 10); 
			c[i + j] =c[i + j] % 10;
		}
	}
	
	lc = la + lb;
	
	for (int i = lc; i >= 1; i--) {
		if (c[i] != 0) {
			break;
		}
		lc--;
	}
	
	for (int i = lc; i > 0; i--) {
		cout << c[i];
	}
	
	return 0;
}
2021/7/6 08:57
加载中...