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. HDU1043 Eight

    题目: 简单介绍一下八数码问题:        在一个3×3的九宫格上,填有1~8八个数字,空余一个位置,例如下图: 1 2 3 4 5 6 7 8           在上图中,由于右下角位置是空的 ...

  2. input点击修改样式

    <input id="geren" type="button" value="个人奖励" style="BORDER-TOP ...

  3. 微信小程序获取当前所在城市

    本篇文章主要讲解在微信小程序中,如何利用微信自带的api(wx.getLocation())结合百度地图的逆地址解析api来获取当前所在城市名. 实现起来也比较简单,步骤为: 1--利用微信小程序接口 ...

  4. DMARC 介绍

    DMARC 是什么? DMARC 是 “Domain-based Message Authentication, Reporting & Conformance” 的缩写.它用来检查一封电邮是 ...

  5. linux ssh文件输

    在linux下一般用scp这个命令来通过ssh传输文件. 1.从服务器上下载文件scp username@servername:/path/filename /var/www/local_dir(本地 ...

  6. POJ 1470 Tarjan算法

    裸的LCA,读入小坑.Tarjan算法大坑,一开始不知道哪儿错了,后来才发现,是vis数组忘了清零了(⊙﹏⊙)b 傻傻的用了邻接矩阵...很慢啊,1100多ms. Closest Common Anc ...

  7. 【Linux】ubuntu中怪异的vi编辑器

    由于前几天一场windows系统的比特币勒索病毒,我下狠心装了Linux的ubuntu版本.可是今天在使用命令行中的vi编辑器时出现了怪异的现象:backspace不能删除,编辑模式回车随机出现字母. ...

  8. jQuery顺序加载图片(终版)

    这一篇是对上一篇(jQuery顺序加载图片(初版)--http://www.cnblogs.com/newbie-cc/p/3707504.html)的改进. function loadImage(i ...

  9. 基于神经网络的混合计算(DNC)-Hybrid computing using a NN with dynamic external memory

    前言: DNC可以称为NTM的进一步发展,希望先看看这篇译文,关于NTM的译文:人工机器-NTM-Neutral Turing Machine 基于神经网络的混合计算 Hybrid computing ...

  10. Linux—Ubuntu14.0.5安装mongo

    1.安装mongo sudo apt-get install mongo 2.如果遇到找不到安装包运行,那就更新资源列表 sudo apt-get update 3.安装成功会自动运行mongo pg ...