hdu 4788

来源:互联网 发布:守望先锋安娜数据 编辑:程序博客网 时间:2024/06/08 03:11
/*hdu 4788该题算是道水题吧,没有什么算法,这是一道成都区域赛的一道训练赛的题,但是个人觉得水题也需要注意,*/# include<iostream># include<cstdio># include<cmath># include<cstring>using namespace std;int main(){    int t,n;    char s[100];    cin>>t;    int p=0;    while(t--)    {        double count=0,a,b,x,sum;        getchar();        gets(s);        int l=strlen(s);        if(s[l-3]=='[') cout<<"Case #"<<++p<<": 0.00%"<<endl;        else {        if(s[l-3]=='K'){count=3;x=10;}        if(s[l-3]=='M'){count=6;x=20;}        if(s[l-3]=='G'){count=9;x=30;}        if(s[l-3]=='T'){count=12;x=40;}        if(s[l-3]=='P'){count=15;x=50;}        if(s[l-3]=='E'){count=18;x=60;}        if(s[l-3]=='Z'){count=21;x=70;}        if(s[l-3]=='Y'){count=24;x=80;}        a=pow(5.0,count+2.0);//这里需注意,应该用5.0不要用5,否则提交就是编译错误        b=pow(2.0,x-count-2.0);        sum=100-a/b;        printf("Case #%d: %.2lf",++p,sum);        cout<<"%"<<endl;        }    }    return 0;}

0 0
原创粉丝点击