Codeforces Round #253 (Div. 1)-A,B
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的更多相关文章
- Codeforces Round #253 (Div. 1) (A, B, C)
Codeforces Round #253 (Div. 1) 题目链接 A:给定一些牌,然后如今要提示一些牌的信息,要求提示最少,使得全部牌能够被分辨出来. 思路:一共2^10种情况,直接暴力枚举,然 ...
- Codeforces Round 253 (Div. 2)
layout: post title: Codeforces Round 253 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- Codeforces Round #253 (Div. 2) D. Andrey and Problem
关于证明可以参考题解http://codeforces.com/blog/entry/12739 就是将概率从大到小排序然后,然后从大到小计算概率 #include <iostream> ...
- 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- ...
- 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 ...
- Codeforces Round #253 (Div. 2) B - Kolya and Tandem Repeat
本题要考虑字符串本身就存在tandem, 如测试用例 aaaaaaaaabbb 3 输出结果应该是8而不是6,因为字符串本身的tanderm时最长的 故要考虑字符串本身的最大的tanderm和添加k个 ...
- Codeforces Round #253 (Div. 2) A. Anton and Letters
题目很简单,只需要注意带空格的输入用getline即可 #include <iostream> #include <vector> #include <algorithm ...
- Codeforces Round #253 (Div. 2), problem: (B)【字符串匹配】
简易字符串匹配,题意不难 #include <stdio.h> #include <string.h> #include <math.h> #include < ...
- 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 ...
- Codeforces Round #253 (Div. 2)B(暴力枚举)
就暴力枚举所有起点和终点就行了. 我做这题时想的太多了,最简单的暴力枚举起始点却没想到...应该先想最简单的方法,层层深入. #include<iostream> #include< ...
随机推荐
- itext 生成doc文档 小结(自己备忘)
1.引入maven <dependency> <groupId>com.lowagie</groupId> <artifactId>itext</ ...
- js,jquery中.each()方法遍历如何终止循环
用.each()方法遍历节点的时候,用“return false”只能终止当前循环并跳入下一次循环,并不能终止所有循环.代码如下: $(".days").each(function ...
- 《CSS Mastery》读书笔记(2)
第二章 目标的样式 要用CSS样式化一个HTML元素,必须要定位一个元素, CSS的选择器就是这样的手段. 这章中,你要学到的 • Common selectors 普通选择器 • Advanc ...
- html5与css3入门知识点精炼
<meta name = "keywords" content="…………"/>(网页搜索时要输入的关键字) <meta name = &qu ...
- 搭建Hive所遇到的坑
##一.基本功能: 1.启动hive时报错 java.lang.ExceptionInInitializerError at java.lang.Class.forName0(Native Metho ...
- sql server 存储过程(事务,带参数声明,数据库瘦身)
CREATE PROCEDURE procedureName (@var1 as varchar(50),@var2 as varchar(50)) --建立未发临时表 AS begin tran - ...
- POJ_2186_Popular Cows_强连通分量
Popular Cows Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 30680 Accepted: 12445 De ...
- MAMP PRO php的session保存在哪里
session的概念就不介绍了,最近接触php,很好奇session会保存在哪里. mac上用了MAMP PRO集成环境,作为服务器. 查了网上,说session的保存路径在php.ini中声明,于是 ...
- turn.js中文API 写一个翻页效果的参数详细解释
$('.flipbook').turn({ width: 922, height: 600, elevation: 50, gradients: true, a ...
- [NOIP2018模拟赛]d
d题大概是让有n个矩阵,可以随意平移,问删除m个矩阵后最大的面积交是多少. 其实思路很显然. 肯定删x个a最小的和m-x个b最小的. 然后我们先删m个a最小的,然后逐渐少删a,开始删b,用个堆维护b的 ...