| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 772 人关注过本帖
标题:[求助] 10的1000000方怎么弄?
只看楼主 加入收藏
karon1988
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-4-5
收藏
 问题点数:0 回复次数:8 
[求助] 10的1000000方怎么弄?
题目:
Problem description

We are not alone.

In the year 3000, scientists have eventually found another planet which has intelligent being living on. Let's say, Planet X. And we call the intelligent being there ‘XMen'. To learn advanced technology from Planet X, we want to exchange information with XMen. Unfortunately, XMen use a very strange data format when sending message, which is called m-encoding (m is for multiplication). Scientists on earth have successfully found out the algorithm of m-encoding, defining as following:

For each data package from XMen, there are two non-negative integer numbers, A and B. And the actual data XMen want to send is the product of A and B (A * B).

So, in this problem, you are to implement a decoder for data packages from XMen.

Input
There are multiple test cases. Input data starts with an integer N, indicating the number of test cases.

Each test case occupies just one line, and contains two non-negative integers A and B (0 <= A, B <= 101000000), separated by just one space.

Output
For each test case, output the actual data XMen want to send, one in a line.

Sample Input
3
1 1
100 123
12345678901234567890 54321
Sample Output
1
12300
670629623593962962352690

那个10 的1000000次方太大了点吧....怎么办?
搜索更多相关主题的帖子: Planet Let XMen Tahoma 
2007-11-01 17:49
manm
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2007-11-1
收藏
得分:0 
怎么全是英文哦  看不懂呢!  汗!
2007-11-01 17:54
karon1988
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-4-5
收藏
得分:0 
主要就是想知道那个那么大的数怎么表示呢?
2007-11-01 18:09
zhouwh
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2007-10-30
收藏
得分:0 

是不是可以用科学计数法啊

2007-11-02 08:45
lctt
Rank: 1
等 级:新手上路
帖 子:24
专家分:0
注 册:2007-10-16
收藏
得分:0 
................
2007-11-02 08:57
nghf
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-10-16
收藏
得分:0 

用大数表示吧,我只知道大数相乘.


毕业后我真的失业了.....后来又就业了!!
2007-11-02 11:43
visolleon
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:71
专家分:182
注 册:2007-1-16
收藏
得分:0 
两个超大的数字相乘的程序:

[CODE]
using System;
using System.Collections.Generic;
using System.Text;

namespace BigNumber
{
class Program
{
static void Main(string[] args)
{
Console.Write("Number A is : ");
string Aa = Console.ReadLine();
int[] A = new int[Aa.Length];
for (int i = 0; i < Aa.Length; i++)
{
A[Aa.Length-1-i] = Convert.ToInt32(Aa.Substring(i, 1));
//Console.WriteLine(A[Aa.Length - 1 - i]);
}

Console.Write("Number B is : ");
string Bb = Console.ReadLine();
int[] B = new int[Bb.Length];
for (int i = 0; i < Bb.Length; i++)
{
B[Bb.Length-1-i] = Convert.ToInt32(Bb.Substring(i, 1));
//Console.WriteLine(B[Bb.Length - 1 - i]);
}
int[,] sum = new int[Aa.Length,Bb.Length];
int[] wsum = new int[Aa.Length + Bb.Length];
for (int i = 0; i < Aa.Length; i++)
{
for (int j = 0; j < Bb.Length; j++)
{
sum[i,j] = A[i]*B[j];
wsum[i + j] = wsum[i + j] + sum[i, j];
if (wsum[i + j].ToString().Length > 1)
{
wsum[i + j + 1] = wsum[i + j + 1] + wsum[i + j]/10;
wsum[i + j] = Convert.ToInt32(wsum[i + j].ToString().Substring(1, 1));
}
Console.WriteLine("sum[" + i + "," + j + "] = {0}", sum[i, j]);
}
}
string end = "";
for (int m = 0; m < Aa.Length + Bb.Length; m++)
{
Console.WriteLine("wsum[" + m + "] = {0}", wsum[m]);
end = wsum[m].ToString() + end;
}
Console.WriteLine();
Console.WriteLine("================================================================");
Console.WriteLine("计算结果为:{0}",end);
Console.ReadLine();
}
}
}

[/CODE]

2007-11-02 15:19
visolleon
Rank: 3Rank: 3
等 级:论坛游侠
威 望:1
帖 子:71
专家分:182
注 册:2007-1-16
收藏
得分:0 
如果需要判断该数是否大于10的1000000次方的话,就将该数字ToString(),然后判断它的Length的长度是否大于1000000

2007-11-02 15:21
zhqifshy
Rank: 1
等 级:新手上路
帖 子:29
专家分:0
注 册:2007-4-1
收藏
得分:0 
在java上可以直接用Math.pow(),但值太大的话就要注意变量类型
long num = (long)Math.pow(10, 1000000);

希望如火,失望如烟,生3命是一边点着火,一边冒着烟。
2007-11-02 17:46
快速回复:[求助] 10的1000000方怎么弄?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017033 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved