int Inversionnumber (char* s,int len)
{
int ans=0; //s Reverse order number
int a,c,g; //each letter occurrence, T is the largest, no need to calculate the number of T occurrences
a=c=g=0;
For (int i=len-1;i>=0;i--)
{
switch (s[i])
{
case ' A ': a++; Break //a is the smallest, no reverse
[Linear algebra] returns the number of reverse orders.
1 # Include 2 Using Namespace STD; 3 // Returns the number of reverse orders. 4 // By default, the standard sequence in descending order is: from small to large. 5 Class Reversed_order 6 {7 Public : 8 Void Num ( Int Newn ); 9 Private : 10
DescriptionOne measure of ' unsortedness ' in a sequence is the number of the pairs of entries, which is out of order with respect to each Other. For instance, with the letter sequence "Daabec", this measure is 5, since D was greater than four letters E is greater than one letter to it right. This measure was called the number of inversions in the sequence. The sequence ' AACEDGG ' have only one inversion (
[Csharp]/** Start the program header annotation.* Copyright and version Declaration of the program* Copyright (c) 2011, a student from the computer College of Yantai University* All rights reserved.* File name: number of occurrences and Reverse Order* Author: Xue Guangchen* Completion date: January 1, October 08, 2011* Version No.: x1.0* Description of tasks and Solutions* Input description:* Problem descri
DNA sortingProblem descriptionone measure of ' unsortedness ' in a sequence was the number of pairs of entries that was out of order W ith respect to all other. For instance, with the letter sequence "Daabec", this measure is 5, since D was greater than four letters E is greater than one letter to it right. This measure was called the number of inversions in the sequence. The sequence ' AACEDGG ' have only
Problem Link: HDU1266 Reverse number. Basic Training level questions, written in C language.Simple question, don't say it.The following C language programs are adopted by AC:/* HDU1266 Reverse number */#include HDU1266 Reverse Number
The question is very simple. Find the number of exchanges in the worst case of quicksort. After understanding it, we know that it should be a reverse-order pair problem of the sequence.
It is found that the nlog (n) sorting speed of Merge Sorting is very good, while in the sorting process, there is a merge process Merge (), here we will merge two ordered series into an ordered series. In the process of me
A sequence composed of 0 .. n-1. Each time you move the first element of the team to the end of the team,
Evaluate the number of minimum reverse pairs of the N sequences
Algorithm : Inserts an element into the line segment tree in sequence. The reverse logarithm of each addition is larger than the inserted
Number of
Reprint please indicate the source, thank you http://blog.csdn.net/ACM_cxlove? Viewmode = ContentsBy --- cxlove
Returns a reverse_prime, which is a 7-digit number and a prime number
First, find all such numbers.
Two operations
Q k: deletes the number K.
Http://uva.onlinejudge.org/index.php? Option = com_onlinejudge Itemid = 8 page = show_problem pro
consists of n positive integers separated by a space, and the first I represents the size of the data that is numbered I.The third line is a positive integer q, indicating that Mato will look at the data for a few days.After the Q line of two positive integers per line L, R, indicating Mato this day to see the [l,r] interval of the file.OutputQ lines, one positive integer per line, indicating the number of times the Mato need to be exchanged this day
Returns information such as Network, mask, broadcast, reverse resolution, subnet number, IP type, etc. based on the IP or subnet enteredModule required for IPY module here is the Python3 version#!/usr/bin/envpython#-*-coding:utf-8-*-fromipyimportipip_s= input (' pleaseinputanipornet-range: ') # Parameters are IP or network segment Ips=ip (ip_s) Iflen (IPs) >1: #网络地址个数 print (' net:%s ' %ips.net ()) #输出网络地
Ideas:In the process of merging and sorting, one step is to remove the small element from the left and right two arrays in the tmp[] array.The array on the right is actually the element on the right side of the original array. When you take the element to the right without taking the element to the left, the remaining elements on the left side are larger than the first element on the right, i.e. they can form an inverse pair. Assuming that there are now n elements left on the right, the inverse
ans[i]=ans[i-1]+ (n+1) -2*num[i]Num[i] is the data at inputAns[i] is the number of reverse order when m=iThe reverse order of ans[0 in a tree-like array#include #include #include using namespace Std;const int maxn=5010;int NUM[MAXN];int TREE[MAXN];int lowbit (int i){Return i (-i);}int getsum (int i){int sum=0;while (i>0){Sum+=tree[i];I-=lowbit (i);}return sum;}vo
poj2299 Ultra-quicksort tree-like array for inverse number Ultra-quicksort
Time Limit: 7000MS
Memory Limit: 65536K
Total Submissions: 49587
Accepted: 18153
DescriptionIn this problem, you has to analyze a particular sorting algorithm. The algorithm processes a sequence of n distinct integers by swapping, adjacent sequence elements until the sequence is Sorted in ascending order. For the i
Poj 2274 The Race (reverse number + line segment tree)The Race
Time Limit:15000 MS
Memory Limit:65536 K
Total Submissions:3237
Accepted:664
Case Time Limit:3000 MS
DescriptionDuring the Annual Interstellar Competition for Tuned Spaceships, N spaceships will be competing. each spaceship I is tuned in such a way that it can accelerate in zero time to its maximu
Topic Links:http://acm.hdu.edu.cn/showproblem.php?pid=2838Main topic:There are n cows lined up in a row. Each cow has a unique "bad temper" value. The range of bad temper is 1~100000. will nowThe cows are reordered so that the cows are ranked in the order in which the bad temper increases. All cows can exchange their positions with each other. But the exchange of spleenThe gas value is x, y two cows, the time required is x+y. Now ask: What is the shortest time it takes to rearrange the cows?Idea
Frosh WeekTime limit:2000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)Total submission (s): 2772 Accepted Submission (s): 923Problem descriptionduring Frosh Week, students play various games-get to know all other and compete against other Teams. In one such-game, all the Frosh-a team stand in a line, and is then asked to arrange themselves according to some crit Erion, such as their height, their birth date, or their student number
InversionTime limit:2000/1000 MS (java/others) Memory limit:131072/131072 K (java/others)Total submission (s): 3171 Accepted Submission (s): 1154Problem Descriptionbobo has a sequence a1,a2,...,. He is allowed to swapadjacentNumbers for no more than k times.Find the minimum number of inversions after his swaps.Note:the number of inversions is the number of pair
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.