日期:2014-05-17  浏览次数:21039 次

求程序运行总时间,不太懂
刚刚看无意点进了那个什么英雄会,然后就去做了这道题
《微软必应·英雄会第三届在线编程大赛:几个bing?》
附上链接
http://hero.csdn.net/Question/Details?ID=215&ExamID=210
下面是我写出来的代码,提交后提示我程序运行总时间大于3S,最后挑战失败。
代码附上

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;

public class Test 
{
   public static  long howmany(string s)
    {
        char[] charList = s.ToCharArray();
        List<int> b = new List<int>();
        List<int> i = new List<int>();
        List<int> n = new List<int>();
        List<int> g = new List<int>();
        for (int j = 0; j < charList.Length; j++)
        {
            if (charList[j] == 'b')
                b.Add(j + 1);
            else if (charList[j] == 'i')
                i.Add(j + 1);
            else if (charList[j] == 'n')
                n.Add(j + 1);
            else if (charList[j] == 'g')
                g.Add(j + 1);
        }
        long count = 0;
        for (int j = 0; j < b.Count; j++)
        {
            for (int k = 0; k < i.Count; k++)
            {
                if (i[k] > b[j])
                {
                    for (int m = 0; m < n.Count; m++)
                    {
                        if (n[m] > i[k])
                        {
                            for (int t =