); in } the the intQueryintLintRintLintRintRT) About { the if(lR) the { the returnSum[rt]; + } - intM= (l+r) >>1; the intret=0;Bayi if(lquery (L,r,lson); the if(r>m) ret+=query (L,r,rson); the returnret; - } - the intX[MAXN]; the intMain () the { the //Read (); - intN; the while(~SCANF ("%d",N)) the { theBuild0, N-1,1);94 intans=0; the for(intI=0; i) the { thescanf"%d",x[i]);98Ans+=query (x[i],n-1,0, N-1,1); Abou
number can be introduced its next sequence of reverse number. The inverse number of the next sequence is regular sum = the previous Sum-a[i]-1-a[i]; If you come up with something like:Sequence 3 6 9 0 8 5 7 4 2 1 Move 3 to the back, then it will reduce the number of reverse order by 3 (0 2 1) but also increase n-a[i]-1.How many times do you ask for it to occur in 1? Specifically, the update function principle is that, from the beginning of the update, each loss of a number in its corresponding
: first use the line tree or tree array to pre-process the original reverse order and, and then launch one by one. The New Reverse Order and generated after each operation, for example, the reverse order at the beginning is 22. If you set 1 to the end, in the past, there was one number smaller than 1 after 1, and this number is 0. When 1 is adjusted to the next, there were eight numbers bigger than 1 before 1, if it is 3, 6, 9, 8, 5, 7, 4, 2, then the reverse order of the new sequence is 22-1 +
Question link:
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1394
Question:
For the number of N numbers composed of the N numbers 0-n-1, define a number in reverse order (the number above is greater than the number below ). Move the first number to the last position to obtain a new sequence and a new number of reverse orders. You can move n-1 times in total to obtain n reverse orders and ask what the minimum number of these N reverse orders is.
So
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1394
The line segment tree calculates the reverse order number. First, the reverse order number (n logn) of the initial array is obtained, and then O (1) releases other Reverse orders. Because the input is 0 -- n-1, the build starts from 0.
Code:
# Include # Include # Include # Include # Include # Include # Include # Include # Include # Include # Include # Include # Include # Include # Include # Include
HDU 1394 Minimum Inversion Number (tree array)
Analysis:First, this is the problem of solving the reverse order number. First, we need to know what the reverse order number is?
In an arrangement, if the front and back positions of a pair of numbers are in the opposite order of size, that is, the front number is greater than the back number, they are called a reverse order. The total number of reverse orders in an arrangement is called the number of
HDU 1394 Minimum Inversion Number (tree array | Line Segment tree)
Question link: Click the open link
For the problem of calculating the number of reverse orders, we usually use a line segment tree or a tree array for maintenance. The tree array code is short and easy to write. Try to write a tree array.
First, find the number of reverse orders in the original arrangement. For each operation, because the first number in the current arrangement is obta
HDOJ 1394 Minimum Inversion Number calculates the Minimum Number of reverse orders of cyclic strings (violent line segment tree)Minimum Inversion NumberTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission (s): 14879 Accepted Submission (s): 9082Problem Description The inversion number of a given number sequence a1, a2,..., an is the number of pairs (ai, aj) that satisfy I For a given sequence of numbers a1,
Address: HDU 1394 You can use the line segment tree to calculate the number of reverse orders. The maintenance information of this question indicates whether each number has been displayed. After each input, the query is performed from the value of the point to n-1. Each time a number is found, because it is found after the number, this number must be larger than this number. That is, a pair of reverse orders, and then the number of reverse orders +
one, at this time the total number of Reverse Order increased the n-1-a-a; I think there are two ways to think of it: 1. Normal search, but the test data is 5000, too large, and every time you look for the number of reverse orders, you have to move one back, Tl, it is highly probable. Give up on this idea. 2 "Line Segment tree, you only need to find the reverse Number of the initial array, You Can recursive the reverse number of other series (according to the above technique ); AC by SWS Que
smallest number of reverse order is how manyExercisesAh, the largest number is N, the first number is thrown to the end, then the number of reverse order reduced num[i]-1, but increased the n-num[i], then just do it!Code://Qscqesze#include #include#include#include#include#include#includeSet>#include#include#include#include#include#includetypedefLong Longll;using namespacestd;//freopen ("d.in", "R", stdin);//freopen ("D.out", "w", stdout);#defineSspeed ios_base::sync_with_stdio (0); Cin.tie (0)#
. Speaking of which, I am always feeling a word,It would be nice if Ubuntukylin and Deepin had some co-operation in wine software and system stability. Or if the Ubuntukylin Software Center can ingest some of the wine applications in the Deepin store, it will certainly make the system more user-friendly. For these reasons, I have the idea of trying to install the wine software supported by Deepin on Ubuntu, Finally I choose to test is QQ8.9 and Thunderbolt
May be the program crashes caused. As with the Thunderbolt 7 crash, there may be a system incompatibility.
1. After the uninstall is recommended, login to: http://dl.xunlei.com/to download the installation again.
2. In addition to reinstallation, it is best to save the crash information by creating a dump file for the task list (pictured below):
This situation generally in the Thunderbolt 7 downlo
A few days ago, the "Financial Times" a name for the "Private user information thunder into a crisis of trust," the article, once again the Thunderbolt pushed to the forefront of public opinion. In fact, as early as last year, Huajun and the sky has been because of Thunder hotlinking and Qi Qi ban. Today, the thunderbolt because of unauthorized uploading user information and into a crisis of trust. Looking
Thunder has not been out of the Linux version, wine do not want to get. Linux, although there are all kinds of BT software, but I tried to find that the speed is far less than thunder, and even some resources can not be found at all. And some of the special link of Thunder, but also can not under (forgive me 2M of small water pipe, but like to watch the American drama). With the advent of various TV boxes and intelligent routing, Thunderbolt got a rem
Please try to dl.xunlei.com click to download the Thunderbolt test.
Note:
① individual website can not be associated with the Thunderbolt, this is due to the problem of the site, but if the site has written support Thunder download, you can feedback to our customer service test download to see if it is normal.
② if it's IE11, please go directly to the internet option = "Advanced =" Remove "enhanced prote
1. How to keep the original download record when upgrading the new version
First back to the Thunder installation directory in the DEFAULT.SDH and history.cfg files, the 2 files saved the original download file information, installed after the new version of the Thunderbolt, the 2 files copied to the Thunderbolt installation directory can be.
2. Right click on the link when did not show "Use Thunder downl
PS1: The home of the old desktop to redo the system, the system is still Thunderbolt 5, because the system of QQ version is older, to be updated to use. On the website download QQ2012, with Thunderbolt 5 downloaded. I this computer tried to use Thunderbolt 7 taste, open on the card, not to mention the next thing. Today when you open the download,
Thunderbolt 7.1.6 release, brought a new drive intelligent speed limit, Internet priority and network speed, with these three functions, we can better co-ordinate bandwidth resources, so that the download does not disturb other network applications.
First, the use of driving intelligent speed limit
1. Understanding Drive Intelligent Speed limit
Sometimes we use the Thunderbolt high-speed download, there
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.