Why CE?
查看原帖
Why CE?
998662
xk2013楼主2024/4/30 20:19

rt,

#include <iostream>
#include <algorithm>
#include <cmath>

int a[1000000], b[1000000], c[1000000000000];

int main(void)
{
	int len;
	
	std::string A, B;
	std::cin >> A >> B;
	
	len = A.length() + B.length();
	
	for (int i = 0; i < A.length(); i++)
	{
		a[i] = A[A.length() - 1 - i] - '0';
	}
	
	for (int i = 0; i < B.length(); i++)
	{
		b[i] = B[B.length() - 1 - i] - '0';
	}
	
	for (int i = 0; i < A.length(); i++)
	{
		for (int j = 0; j < B.length(); j++)
		{
			c[i + j] += a[i] * b[j];
		}
	}
	
	for (int i = 0; i < len; i++)
	{
		c[i + 1] += c[i] / 10;
		c[i] %= 10;
	}
	
	while (c[len - 1] == 0 && len > 1)
	{
		len--;
	}
	
	for (int i = len - 1; i >= 0; i--)
	{
		std::cout << c[i];
	}
	
	return 0;
}
No valid executable file was produced by the compiler
/tmp/compiler__c7y6gjx/src: 在函数‘int main()’中:
/tmp/compiler__c7y6gjx/src:16:20: 警告:comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   16 |  for (int i = 0; i < A.length(); i++)
      |                  ~~^~~~~~~~~~~~
/tmp/compiler__c7y6gjx/src:21:20: 警告:comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   21 |  for (int i = 0; i < B.length(); i++)
      |                  ~~^~~~~~~~~~~~
/tmp/compiler__c7y6gjx/src:26:20: 警告:comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   26 |  for (int i = 0; i < A.length(); i++)
      |                  ~~^~~~~~~~~~~~
/tmp/compiler__c7y6gjx/src:28:21: 警告:comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
   28 |   for (int j = 0; j < B.length(); j++)
      |                   ~~^~~~~~~~~~~~
./cc8R6NVK.o: in function `_GLOBAL__sub_I_src':
src:(.text.startup+0x247): relocation truncated to fit: R_X86_64_PC32 against `.bss'
src:(.text.startup+0x261): relocation truncated to fit: R_X86_64_PC32 against `.bss'
collect2: 错误:ld 返回 1
2024/4/30 20:19
加载中...