Codeforces Gym 100637G G. #TheDress 暴力

本文探讨了一种关于蓝色与黑色衣物在文化中可能代表地球起源的假说。通过对一组受访者提供的关于某件疑似地球人礼服颜色的回答进行分析,本文揭示了如何通过颜色判断个体来自地球、另一星球还是本地生物,并详细解释了这一现象背后的逻辑。通过数据收集和分析,我们得出了地球人、本地生物和外来访客在该群体中的比例,为跨文明交流提供了有趣的视角。

G. #TheDress

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/gym/100637/problem/G

Description

After landing on planet i1c5l people noticed that blue and black clothes are quite popular among the locals. Each aboriginal has at least one blue-and-black piece of clothing in their wardrobe. This makes no interest except one curious detail: the locals claimed that these colors weren’t blue and black but white and gold.

Thus a simple test was created to differ a human being from an alien. On one of the wedding parties people took a picture of the blue-and-black groom mother’s dress. This picture was shown to some respondents who were asked the color of the dress. If the answer contained «blue» and «black» then there was no doubt that the respondent was from the Earth. The answer containing «white» and «gold» pointed to the person of planet i1c5l origin. If the answer contained neither of word pairs then it was clear that the respondent was a creature from another planet.

You have the complete survey log from planet i1c5l. Your task is to determine the constitution of the planet’s population based on the survey.

Input

The first line contains single integer N — the number of respondents (1 ≤ N ≤ 100). The following N lines contain the answers. No line is empty and no line is longer than 100 characters. The answer contains only lower-case Latin letters and spaces. It is guaranteed that no answer can contain «blue», «black», «white», and «gold» simultaneously.

Output

Output three numbers that describe the planet’s population, each on separate line.

The first number — percentage of earthlings in population.

The second number — percentage of aboriginals in population.

The third number — percentage of another planet creatures in population.

Output all numbers with 10 - 5 accuracy.

Sample Input

3
goldandwhite
white and pinkman
blueblueblue and a little bit black

Sample Output

33.3333333333
33.3333333333
33.3333333333

HINT

 

题意

问你回答中含有蓝黑的人,和含有白金的人,和普通人各占百分之多少

题解:

暴力找就好了……

代码

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
#include <map>
#include <stack>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
#define test freopen("test.txt","r",stdin)
const int maxn=202501;
#define mod 1000000007
#define eps 1e-9
const int inf=0x3f3f3f3f;
const ll infll = 0x3f3f3f3f3f3f3f3fLL;
inline ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//**************************************************************************************

string s;
int find_blue()
{
    int flag1=0,flag2=0;
    int pos=s.find("blue");
    int pos1=s.find("black");
    if(pos!=s.npos)
        flag1++;
    if(pos1!=s.npos)
        flag2++;
    if(flag1==1&&flag2==1)
        return 1;
    return 0;
}
int find_gold()
{
    int flag1=0,flag2=0;
    int pos=s.find("white");
    int pos1=s.find("gold");
    if(pos!=s.npos)
        flag1++;
    if(pos1!=s.npos)
        flag2++;
    if(flag1==1&&flag2==1)
        return 1;
    return 0;
}
double ans1=0,ans2=0,ans3=0;
int main()
{
    int n=read();
    for(int i=0;i<n;i++)
    {
        getline(cin,s);
        if(find_blue())
            ans1+=1;
        else if(find_gold())
            ans2+=1;
        else
            ans3+=1;
    }
    double sum=ans1+ans2+ans3;
    printf("%.10f\n%.10f\n%.10f\n",ans1/sum*100,ans2/sum*100,ans3/sum*100);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值