A题:

由题意可知,最多翻10次就能够(事实上8次就够了)。那么我们就用状态压缩表示状态。

对于某种状态,假设某一位为0,那么代表这一位不翻,否则代表这一位翻。

对于某一种翻的状态:

假设牌中有G3,那么就把G和3进行连边。

其它的连边类似。不要重边。

对于随意一条边的两个端点。分三种情况讨论:

1。两个端点都翻了,那么非常明显,这张牌被表示出来了。

2,两个端点中仅仅有一个端点被翻。那么这个相应的num加1.

3,两个端点都没有被翻,计数器tt加1。

对于随意一种状态:

1,假设计数器tt大于1,那么肯定不能推断出全部的牌。

2。假设随意一个端点的num数大于1。那么也肯定不能推断出全部的牌。

3。否则的话,这样的状态能够表示出全部的牌。

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define LL __int64
#define maxn 2201
int 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;
}

B题:

对于当前选择的状态,

p0表示0个人告诉答案的概率。

p1表示1个人告诉答案的概率。

对于即将面对的一个人:

a表示0个人告诉答案的概率。

b表示1个人告诉答案的概率。

假设接纳这个人之后,p1的值变小了。那么就不应该接纳下去。

#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
#define LL __int64
#define maxn 2201
double 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;
}

Codeforces Round #253 (Div. 1)-A,B的更多相关文章

  1. Codeforces Round #253 (Div. 1) (A, B, C)

    Codeforces Round #253 (Div. 1) 题目链接 A:给定一些牌,然后如今要提示一些牌的信息,要求提示最少,使得全部牌能够被分辨出来. 思路:一共2^10种情况,直接暴力枚举,然 ...

  2. Codeforces Round 253 (Div. 2)

    layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  3. Codeforces Round #253 (Div. 2) D. Andrey and Problem

    关于证明可以参考题解http://codeforces.com/blog/entry/12739 就是将概率从大到小排序然后,然后从大到小计算概率 #include <iostream> ...

  4. Codeforces Round #253 (Div. 2) D题

    题目大意是选出一个其他不选,问问最大概率: 刚开始想到DP:F[I][J][0]:表示从 前I个中选出J个的最大值, 然后对于F[I][J][1]=MAX(F[I-1][J][1],F[I-1][J- ...

  5. Codeforces Round #253 (Div. 1) A. Borya and Hanabi 暴力

    A. Borya and Hanabi Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/442/p ...

  6. Codeforces Round #253 (Div. 2) B - Kolya and Tandem Repeat

    本题要考虑字符串本身就存在tandem, 如测试用例 aaaaaaaaabbb 3 输出结果应该是8而不是6,因为字符串本身的tanderm时最长的 故要考虑字符串本身的最大的tanderm和添加k个 ...

  7. Codeforces Round #253 (Div. 2) A. Anton and Letters

    题目很简单,只需要注意带空格的输入用getline即可 #include <iostream> #include <vector> #include <algorithm ...

  8. Codeforces Round #253 (Div. 2), problem: (B)【字符串匹配】

    简易字符串匹配,题意不难 #include <stdio.h> #include <string.h> #include <math.h> #include < ...

  9. Codeforces Round #253 (Div. 1) B. Andrey and Problem

    B. Andrey and Problem time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  10. Codeforces Round #253 (Div. 2)B(暴力枚举)

    就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...

随机推荐

  1. go之for循环

    一.基于计数器的迭代 格式 for 初始化语句; 条件语句; 修饰语句{} 实例 package main import "fmt" func main(){ for i:=0;i ...

  2. C#发送电子邮件代码记录

    /// <summary> /// 发送电子邮件 /// </summary> /// <param name="Address">邮件地址&l ...

  3. C - Stones on the Table

    Problem description There are n stones on the table in a row, each of them can be red, green or blue ...

  4. MySQL学习笔记之右连接

    MySQL的右连接 #右连接,以右表为基表 select course.stuid,course.stuname,sex,course,city from class1 right join cour ...

  5. 使用IDEA 搭建一个SpringBoot + Hibernate + Gradle

    ---恢复内容开始--- 打开IDEA创建一个新项目: 第一步: 第二步: 第三步: 最后一步: 如果下载的时候时间太久.可以找到build.gradle文件,添加以下代码.如下图 maven{ ur ...

  6. Combotree--别样的构建层级json字符串

    1.先看效果 2.需要使用层级json格式,如: 3.先不要着急怎么去实现它,先来想想怎么用对象来描述它 4.代码 protected void Page_Load(object sender, Ev ...

  7. ie8及其以下版本兼容性问题之响应式

    解决办法:引入Respond.js让IE6-8支持CSS3 Media Query 使用方式 参考官方demo:http://scottjehl.github.com/Respond/test/tes ...

  8. halcon 模板匹配 -- find_shape_model

    find_shape_model(Image : :  //搜索图像 ModelID, //模板句柄 AngleStart,  // 搜索时的起始角度 AngleExtent, //搜索时的角度范围, ...

  9. 【sqli-labs】 less43 POST -Error based -String -Stacked with tiwst(POST型基于错误的堆叠变形字符型注入)

    和less42一样 login_user=&login_password=1');insert into users(id,username,password) value(15,'root' ...

  10. UNIX SOCKET编程简介

    1  .  Layered Model of Networking Socket  编程的层次模型如下图所示,   最上面是应用层,应用层下面的是  SOCKET API  层,再下面是传输层和网络层 ...