UVA-1636-Headshot

来源:互联网 发布:淘宝卖家中心下载 编辑:程序博客网 时间:2024/05/26 19:18

其实这道题不至于写题解,写个题解我只是为了说:这道题十分简单,直接AC就可以了。(有了D神般的成就感)

#include<stdio.h>#include<iostream>#include<math.h>#include<string.h>using namespace std;int main(){    char str[105];    while(cin>>str)    {        double p1,p2;  //p1是不需要转的存活率,p2是需要转的        int huo = 0,si = 0,len = strlen(str);        for(int i = 0;i < len - 1;i++)        {            if(str[i] == '0' && str[i + 1] == '1') si++;            if(str[i] == '0' && str[i + 1] == '0') huo++;        }        if(str[len - 1] == '0' && str[0] == '1') si++;        if(str[len - 1] == '0' && str[0] == '0') huo++;        p1 = (double) huo * 1.0 / (huo + si);        int huo2 = 0;        for(int i = 0;i < len;i++)            if(str[i] == '0') huo2++;        p2 = (double) huo2*1.0/len;        double p3 = p1 - p2;//        printf("%lf %lf\n",p1,p2);        if(p3 < 1e-6 && p3 > -1e-6) printf("EQUAL\n");        else if(p3 > 0) printf("SHOOT\n");        else printf("ROTATE\n");    }    return 0;}

0 0
原创粉丝点击