Cut the Cake(大数相乘)】的更多相关文章

  MMM got a big big big cake, and invited all her M friends to eat the cake together. Surprisingly one of her friends HZ took some (N) strawberries which MMM likes very much to decorate the cake (of course they also eat strawberries, not just for dec…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 300    Accepted Submission(s): 135 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake toge…
题目链接:http://poj.org/problem?id=2389 题目大意: 大数相乘. 解题思路: java BigInteger类解决 o.0 AC Code: import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.h…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 263    Accepted Submission(s): 113 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake toge…
#include <iostream> #include <cstring> using namespace std; #define null 0 #define MAXN 51 //大数相乘 char *big_cheng(char line1[], char line2[]) { short s1[MAXN], s2[MAXN], s[MAXN];//s1,s2:两个乘数:s:乘积的结果 int i, j, k, c; int len1, len2, len; len1 =…
在搞ACM的时候遇到大数相乘的问题,在网上找了一下,看到了一个c++版本的 http://blog.csdn.net/jianzhibeihang/article/details/4948267 用java搞了一个版本 这里说一下思路 将数字已字符串形式接收,转换成int[]整型数组,然后num1[],num2[]依次相乘,结果保存到result[]中 其他注意的在注释中有说明 package com.gxf.test; import java.util.Scanner; public clas…
最近写了一个大数相乘和相加的程序,结果看起来是对的.不过期间的效率可能不是最好的,有些地方也是临时为了解决问题而直接写出来的. 可以大概说一下相乘和相加的解决思路(当然,大数操作基本就是两个字符串的操作了): 一.思路: 在操作大数前,一定会有一些异常判断,比如输入的字符串是否合法(是否是纯数字?是否为空?等等),然后才是具体的操作实现: 1.大数相加(大体思路:将大数相加问题,转换成十以内的两数相加): ①申请合适的空间,一般可以认定,两个数字相加时,长度至多是最长的数的长度或最长的数的长度加…
Karatsuba乘法 Karatsuba乘法是一种快速乘法.此算法在1960年由Anatolii Alexeevitch Karatsuba 提出,并于1962年得以发表.此算法主要用于两个大数相乘.普通乘法的复杂度是n2,而Karatsuba算法的复杂度仅为3nlog3≍3n1.585(log3是以2为底的). 算法介绍 步骤简介 Karatsuba算法主要应用于两个大数的相乘,原理是将大数分成两段后变成较小的数位,然后做3次乘法,并附带少量的加法操作和移位操作. 现有两个大数,x,y. 首…
Cut the Cake Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1657    Accepted Submission(s): 806 Problem Description MMM got a big big big cake, and invited all her M friends to eat the cake tog…
感觉是大数相乘算法里面最能够描述.模拟演算过程的思路 class Solution { public String multiply(String num1, String num2) { if(num1.charAt(0) == '0' || num2.charAt(0) == '0'){ return "0"; } int len1 = num1.length(); int len2 = num2.length(); int len = len1+len2; int[] arr =…