Pair development Five--the maximum number of sub-arrays for a one-dimensional array of 1000-digit long type

Source: Internet
Author: User

First, design ideas

We then let him automatically generate 1000 random long numbers based on the first experiment. Roughly the same as the experiment, I have buried myself in a bomb.

Second, the experimental code

Package Com.minirisoft;import Java.util.*;class supermax{public static void Main (string[] args) {long[] list = new long[10 00];//input array is an array must be defined first, otherwise an error! long[] arr1 = new long[1000];//input array is an array that must be defined before an error occurs! System.out.println ("Enter array:"); for (int k=0;k<1000;k++) {random t=new random (); List[k]=t.nextlong (); if (k==500) list [500]= (Long) Math.pow (2,10000);} for (int n=0;n<999;n++) {arr1[n]=list[n];for (int m=n;m<999;m++) {arr1[m+1]=arr1[m]+list[m+1];} for (int m=n;m<1000;m++) {if (Arr1[m]>arr1[n]) {arr1[n]=arr1[m];}} System.out.println ("from" + (n+1) + "The maximum number of sub-arrays of radiation of elements and" +arr1[n]);} ARR1[999]=LIST[999]; System.out.println ("The maximum number of sub-arrays radiating from the 1000th element is" +arr1[999 "); for (int i=0;i<1000;i++) {if (arr1[i]>arr1[0]) {arr1[0]= Arr1[i];}} System.out.println ("Maximum subarray of" and "+arr1[0]);}}

Third, the experimental results

Iv. Experience

This experiment, let me know to consider the type of number, see whether cross-border. But now I feel very puzzled by my own procedure. It is obviously long length range to 2^64 but has received more than the number of times, but no error.

V. Panel members: Yang Guangxin, Guo Jianhao

Pair development Five--the maximum number of sub-arrays for a one-dimensional array of 1000-digit long type

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.