下面是别人给我的代码: package com.bootdo; public class Test { public static void main(String[] args) { System.out.println(multiply("2354343543543", "3213213213")); } public static String multiply(String num1, String num2) { int l = num1.length()
"""思路:1.a * b = a + a + a + ... 2.a * b = n个a相加,只需求证b = n即可 3.用for 循环遍历即可,b就是range的最大次数 4.需考虑a,b有五种情况存在,但结果会有三种,正数,0,负数""" def multiplication(a,b): if a > 0 and b > 0: sum = 0 for i in range(b): sum += a print(sum) elif
题目描述: Find the largest palindrome made from the product of two n-digit numbers. Since the result could be very large, you should return the largest palindrome mod 1337. Example: Input: 2 Output: 987 Explanation: 99 x 91 = 9009, 9009 % 1337 = 987 Note
Given two numbers represented as strings, return multiplication of the numbers as a string. Note: The numbers can be arbitrarily large and are non-negative. 这道题让我们求两个字符串数字的相乘,输入的两个数和返回的数都是以字符串格式储存的,这样做的原因可能是这样可以计算超大数相乘,可以不受int或long的数值范围的约束,那么我们该如何来计算
两个字符串表示两个非常大的数,请设计算法计算这两个大数的乘积,结果用字符串表示.例如S1="7832974972840919321747983209327",S2="1987432091904327543957",设计算法计算出S1*S2的结果,结果用String输出,不准用BigInter. 思路: 根据手工计算两数相乘的过程,用代码实现这个过程. 代码: import java.util.Scanner; public class DaZhengShuCheng