zoukankan      html  css  js  c++  java
  • 别再打了,Java和Python,你们其实都是C

      考试加上懒得写代码,休息了一个多周

      ……其实考试的因素很大啦……

      

      坐着火车不知道干什么好,研究了半天GUI,什么也没搞懂,加上终于学会用BigInteger了,就算了下斐波那契数列。

      然后我就发现了,在我电脑算到死机之前,Java和Python的速度差距很小。

    BigInteger num1 = new BigInteger("1");
    BigInteger num2 = new BigInteger("1");
    BigInteger temp;
    int count = 0;
    
    while (count < 100000) {
        temp = num1;
        num1 = num2;
        num2 = temp.add(num2);
        
        count++;
    }
    
    System.out.println(num2);

      对的,算十万个秒出,算一百万个就卡住了……

      还是Python代码简单一点……

  • 相关阅读:
    Add Two Numbers
    Reverse Linked List II
    Reverse Linked List
    Remove Duplicates from Sorted List
    Remove Duplicates from Sorted List II
    Partition List
    Intersection of Two Linked Lists
    4Sum
    3Sum
    2Sum
  • 原文地址:https://www.cnblogs.com/chihane/p/3500318.html
Copyright © 2011-2022 走看看