如题
解决方案 »
- “对象的引用”是什么意思?
- 关于 的问题
- D3DES加密问题
- fireActionPerformed是作什么用的?
- 如何用java写messagebox?
- jdbc连接ms数据库的问题请教,不知道是我的代码有问题还是机子的问题,请各位大哥指点指点
- 在JFrame的构造函数以外add contentpane为何不会马上显示出来,而是要自己把窗口放大些或者最大化才能显示
- 麻烦打架帮我看一下,究竟是哪里出了问题!!谢谢!!
- Bigger type length than Maximum
- 有谁知道tomcat中如何把访问:http://132.21.25.12/oa 配置为 http://132.21.25.12 就可以访问?多谢!
- 如何在JFrame或JPanel里添加背景图片
- 无法调用servlet /relogin.jsp的service()方法
绝对有用的:
“擂台赛:计算n!(阶乘)的精确值,速度最快者2000分送上(续)”
http://topic.csdn.net/t/20031105/00/2427925.html50楼后就是代码分析了
import java.math.BigInteger;
public class TestCheng{
public void testCheng(){
BigInteger big = new BigInteger("1");
for(int i=1;i<=50000;i++){
big = big.multiply(new BigInteger(""+i));
}
System.out.println(big.toString());
}
public static void main(String[] args){
new TestCheng().testCheng();
}
}
AMD 3000+ 1.5G内存 用了49秒......
高精度快速阶乘算法 :
http://dev.csdn.net/article/29/29226.shtm
结果到word文档 小5字体 10页多一点
里面有!
int N = Integer.parseInt(args[0]);
int[] a = new int[N * 5];
int n = N;
int m = 0;
int c = 0;
int i = 0;
Date start = new Date();
a[0] = 1;
for (; n > 1; n--) {
for (c = i = 0; i <= m; i++) {
a[i] = (c += a[i] * n) % 10;
c /= 10;
}
while (c > 0) {
a[++m] = c % 10;
c /= 10;
}
}
System.out.println(i);
System.out.println(m);
n = 0;
for (; m >= 0; m--) {
n = n + a[m];
}
System.out.println(n);
Date end = new Date();
System.out.println("冯冰:" + (end.getTime() - start.getTime()) + ":" + n);
}
}告诉大家一个方法可以硬性提高jvm速度 就是执行参数中加入 -server