Codeforces Round #253 (Div. 1)-A,B_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:02:44
Original
983 people have browsed it

Question A:

From the meaning of the question, it can be turned over up to 10 times (in fact, 8 times is enough), then we use state compression to represent the state.

For a certain state, if a certain bit is 0, it means that this bit is not turned over, otherwise it means that this bit is turned over.

For a certain flip state:

If there is G3 in the card, then connect G and 3. The other connected edges are similar, don’t repeat the edges.

For the two endpoints of any edge, there are three situations to discuss:

1. If both endpoints are turned over, then it is obvious that this card is represented.

2, only one of the two endpoints is turned over, then the corresponding num is increased by 1.

3, both endpoints are not turned over, and the counter tt is increased by 1.

For any state:

1, if the counter tt is greater than 1, then all cards cannot be determined.

2. If the num number of any endpoint is greater than 1, then it will definitely not be able to determine all the cards.

3, otherwise, this state can represent all cards.

#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<vector>using namespace std;#define LL __int64#define maxn 2201int num[20];int pan[220];int name[22001];vector<int>vec;int map[110][110];void dos(int x){    while(x)    {        cout<<x%2;        x=x/2;    }    cout<<endl;}int main(){    int n,l,r,x,y;    char str[1010];    pan['R']=6;    pan['G']=7;    pan['B']=8;    pan['Y']=9;    pan['W']=5;    while(~scanf("%d",&n))    {        memset(num,0,sizeof(num));        memset(name,0,sizeof(name));        memset(map,0,sizeof(map));        l=r=0;        for(int i=1; i<=n; i++)        {            scanf("%s",str);            x=pan[str[0]];            y=str[1]-'1';            map[x][y]++;            map[y][x]++;        }        int st=0;        int minn =10;        for(int st=0; st<(1<<10); st++)        {            int ss=0;            for(int j=0; j<10; j++)            {                if(st&(1<<j))ss++;            }            if(ss>=minn)continue;            int leap=0;            int t=0;            memset(num,0,sizeof(num));            for(int j=5; j<10; j++)            {                for(int i=0; i<5; i++)                {                    if(map[i][j])                    {                        if((st&(1<<i))&&(st&(1<<j)))continue;                        if((st&(1<<i))||(st&(1<<j)))                        {                            if(st&(1<<i))                            {                                if(!num[i])                                {                                    num[i]++;                                    continue;                                }                            }                            if((st&(1<<j)))                            {                                if(!num[j])                                {                                    num[j]++;                                    continue;                                }                            }                        }                        else                        {                            if(t==0)                            {                                t++;                                continue;                            }                        }                        leap++;                    }                }            }            if(!leap)            {                minn=min(minn,ss);             //   cout<<" "<<ss<<" ";              //  dos(st);            }        }        cout<<minn<<endl;    }    return 0;}
Copy after login
Question B:

For the current selected state,

p0 represents the probability of 0 people telling the answer.

p1 represents the probability of one person telling the answer.

For the person you are about to face:

a represents the probability of 0 people telling the answer.

b represents the probability of 1 person telling the answer.

If the value of p1 becomes smaller after accepting this person, then it should not be accepted.

#include<stdio.h>#include<string.h>#include<algorithm>#include<iostream>#include<vector>using namespace std;#define LL __int64#define maxn 2201double num[maxn];int main(){    int n;    double x;    while(~scanf("%d",&n))    {        for(int i=1;i<=n;i++)        {            scanf("%lf",&num[i]);        }        sort(num+1,num+n+1);        double ans=0;        double a=1;        double c,d;        double b=0;        for(int i=n;i>=1;i--)        {            c=a;            d=b;            b=b+a*num[i]-b*num[i];            a=a-a*num[i];            if(b<d)            {                b=d;                break;            }        }        printf("%.10lf\n",b);    }    return 0;}
Copy after login












Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template