C# ACM poj1007
求逆序数,快排
public static void acm1007(int a, string[] c)
{
Dictionary<int, string> dic = new Dictionary<int, string>();
int[] i = new int[a];
var j = ;
foreach (var item in c)
{
int k = Acm1007Unit(item);
if (!dic.ContainsKey(k))
{
i[j] = k;
j++;
dic.Add(k, item + ",");
}
else
{
dic[k] += item + ",";
i[j] = -;
j++;
}
}
QSortDIY(i, , i.Length - ); for (int jjj = ; jjj < i.Length ; jjj++)
{
if (i[jjj] != -)
{
Console.Write(dic[i[jjj]]);
}
} }
public static int Acm1007Unit(string a)
{
int anum = ;
int cnum = ;
int gnum = ; int r = ;
for (int i = a.Length - ; i >= ; i--)
{
switch (a[i])
{
case 'A':
anum++;
break;
case 'C':
r += anum;
cnum++;
break;
case 'G':
r += anum + cnum;
gnum++;
break;
case 'T':
r += anum + cnum + gnum;
break;
}
}
return r;
}
public static void QSortDIY(int[] array, int low, int high)
{
if (low >= high)
{
return;
}
int ie = QSortUnit(array, low, high);
QSortDIY(array, low, ie - );
QSortDIY(array, ie + , high);
}
private static int QSortUnit(int[] array, int low, int high)
{
int key = array[low];
while (low < high)
{
while (array[high] >= key && high > low)
{
--high;
}
array[low] = array[high];
while (array[low] <= key && high > low)
{ ++low;
}
array[high] = array[low];
}
array[low] = key;
return high;
}
C# ACM poj1007的更多相关文章
- ACM训练计划建议(写给本校acmer,欢迎围观和指正)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
- ACM训练计划建议(转)
ACM训练计划建议 From:freecode# Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...
- 北大ACM - POJ试题分类(转自EXP)
北大ACM - POJ试题分类 -- By EXP 2017-12-03 转载请注明出处: by EXP http://exp-blog.com/2018/06/28/pid-38/ 相关推荐文: 旧 ...
- SCNU ACM 2016新生赛决赛 解题报告
新生初赛题目.解题思路.参考代码一览 A. 拒绝虐狗 Problem Description CZJ 去排队打饭的时候看到前面有几对情侣秀恩爱,作为单身狗的 CZJ 表示很难受. 现在给出一个字符串代 ...
- SCNU ACM 2016新生赛初赛 解题报告
新生初赛题目.解题思路.参考代码一览 1001. 无聊的日常 Problem Description 两位小朋友小A和小B无聊时玩了个游戏,在限定时间内说出一排数字,那边说出的数大就赢,你的工作是帮他 ...
- acm结束了
最后一场比赛打完了.之前为了记录一些题目,开了这个博客,现在结束了acm,这个博客之后也不再更新了. 大家继续加油!
- 关于ACM的总结
看了不少大神的退役帖,今天终于要本弱装一波逼祭奠一下我关于ACM的回忆. 从大二上开始接触到大三下结束,接近两年的时间,对于大神们来说两年的确算不上时间,然而对于本弱来说就是大学的一半时光.大一的懵懂 ...
- 第一届山东省ACM——Phone Number(java)
Description We know that if a phone number A is another phone number B’s prefix, B is not able to be ...
- 第一届山东省ACM——Balloons(java)
Description Both Saya and Kudo like balloons. One day, they heard that in the central park, there wi ...
随机推荐
- jsDoc注释的规范
注释以/** 开始 */结束 JSDoc 命令属性 命令名 描述 @param @argument 指定参数名和说明来描述一个函数参数. @return @returns 描述函数的返回值. ...
- EASYUI- EASYUI左移右移 GRID中值
EASYUI左移右移 GRID中值 $("#addAll").click(function(){ var ids = []; var names = []; var srcrows ...
- android飞机游戏敌机移动路径
基础android的飞机类游戏,与前人一样,由surfaceView绘制游戏画面,另起线程控制绘制时间间隔达到动态效果.这里附上最近自己写的敌机自动飞行路径代码.请大家给点意见. 在敌机管理模块,加入 ...
- node.js在windows下的学习笔记(4)---同步,异步,回调的概念
Node.js是使用事件驱动的,非阻塞的I/O模型,用于构建快速的,可扩展的网络应用程序. Node.js想解决的问题是:处理输入,输入,高并发 1.阻塞与非阻塞 阻塞也叫同步,是指每一次执行一个操作 ...
- [MODx] 4. getResources
1. Create a chunk call 'white_content' for white content: <!-- Highlights --> <div class=&q ...
- [Node.js] Using npm link to use node modules that are "in progress"
It is some times convenient, even necessary, to make use of a module that you are working on before ...
- javascript中false值及其常见比较运算
1. ture或者false的值 if判断中会被隐式转换成false的boolean类型的值有 false, 0, undefined , null , '', NaN(not a number) 除 ...
- C#_delegate - 异步调用实例 BeginInvoke EndInvoke event
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Encryption
Encryption Configuration Basic Usage Encrypting a value Decrypting a value Configuration Before usin ...
- Android_ViewPager
view1源代码及xml资源文件: <?xml version="1.0" encoding="utf-8"?> <LinearLayout ...