讨论 / 这也能过..
corn 2010-11-07 16:23:00
点我顶贴 收藏 删除
汗颜..本来想玩玩,打了一个简短的枚举提交

额..没想到就过了..这数据也太弱了吧..

状态: Accepted

测评机: Xeost[5]

得分: 100分

提交日期: 2010-9-28 8:44:00

有效耗时: 2093毫秒

测试结果1: 通过本测试点|有效耗时343ms

测试结果2: 通过本测试点|有效耗时532ms

测试结果3: 通过本测试点|有效耗时46ms

测试结果4: 通过本测试点|有效耗时219ms

测试结果5: 通过本测试点|有效耗时203ms

测试结果6: 通过本测试点|有效耗时453ms

测试结果7: 通过本测试点|有效耗时47ms

测试结果8: 通过本测试点|有效耗时47ms

测试结果9: 通过本测试点|有效耗时47ms

测试结果10: 通过本测试点|有效耗时156ms

提交代码:

Program t165;

Var s:ansistring;

len,sum,i,j,n,k:longint;

Begin

readln(s);

len:=length(s);

For i:=1 to len-2 do

if s[i]='F' then

For j:=i+1 to len-1 do

if s[j]='B' then

For k:=j+1 to len do

if s[k]='I' then inc(sum);

Writeln(sum);

end.

#1 whlhc888@2010-11-07 16:23:00
回复 删除
为什么我用CPP做超时呢?

#include<iostream>

#include<string.h>

using namespace std;

long long s;

char d[2002];

int work(int n,int m){

int i;

if(n==0){for(i=m;i<=strlen(d)-3;i++)if(d[i]=='F')work(1,i+1);}

else if(n==1){for(i=m;i<=strlen(d)-2;i++)if(d[i]=='B')work(2,i+1);}

else if(n==2)for(i=m;i<=strlen(d)-1;i++)if(d[i]=='I')s++;

return 0;

}

int main(){

cin>>d;

s=0;

work(0,0);

cout<<s<<endl;

return 0;

}

查看更多回复
提交回复