<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ~~~ # Computer Transformation Time Limit: 2000/1000 MS (Java/Others)????Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6916????Accepted Submission(s): 2504 ~~~ Problem Description A sequence consisting of one digit, the number 1 is initially written into a computer. At each successive time step, the computer simultaneously tranforms each digit 0 into the sequence 1 0 and each digit 1 into the sequence 0 1. So, after the first time step, the sequence 0 1 is obtained; after the second, the sequence 1 0 0 1, after the third, the sequence 0 1 1 0 1 0 0 1 and so on.? How many pairs of consequitive zeroes will appear in the sequence after n steps?? Input Every input line contains one natural number n (0 < n ≤1000). Output For each input n print the number of consecutive zeroes pairs that will appear in the sequence after n steps. Sample Input ~~~ 2 3 ~~~ Sample Output ~~~ 1 1 ~~~ 本題看起來也不難,但是注意一個問題就是當輸入的數值達到大約在40左右的時候,普通的int類型的數據就會發生溢出,無法存放這么大的數字,這就是大數啦,所以需要你特別的對大數進行一定的處理才能使得不發生溢出。一開始我做的時候就是沒有考慮到這個問題所以感覺結果明明是對的呀,但是就是一直出錯,后來終于發現大數溢出的問題,稍微改了下就好了。 ~~~ import java.math.BigDecimal; import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while(scanner.hasNext()) { int num = scanner.nextInt(); BigDecimal sum = new BigDecimal(0); sum = funct(num); System.out.println(sum); } } public static BigDecimal funct(int i) { BigDecimal[] array = new BigDecimal[i+1]; int sum = 0; array[1] = new BigDecimal(0); if(i == 1) return array[1]; array[2] = new BigDecimal(1); for(int j = 3; j <= i ; j++) { array[j] = array[j - 1].add(array[j - 2].multiply(new BigDecimal(2))) ; } return array[i]; } } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看