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< ...
随机推荐
- javascript之模块加载方案
前言 主要学习一下四种模块加载规范: AMD CMD CommonJS ES6 模块 历史 前端模块化开发那点历史 require.js requirejs 为全局添加了 define 函数,你只要按 ...
- Java 网络IO编程(BIO、NIO、AIO)
本概念 BIO编程 传统的BIO编程 代码示例: public class Server { final static int PROT = 8765; public static void main ...
- java bean转Map
/** * @author xxxxxxxxxxx * @param object * 待转化类 * @param format自定义转化类型 * @return Map<String,Stri ...
- 前端HTML中float学习笔记
float元素原本的作用是用来使文字包裹图片,现在人们更多的是用来进行布局(ps:有没有点滥用的意思) 也就是说本来你排好的界面设计,但是因为浮动会导致元素脱离文档流,使得其他非浮动的块级元素会无视这 ...
- ListView使用、ListView优化和遇到的问题
1.先写遇到的问题: a.ListView只显示一个item. listview只显示一个item,并且做了listview的点击事件监听打印 Bean 对象的属性和哈希值,发现只有显示的那个 Bea ...
- opengl使用FreeType绘制字体
原文地址:http://www.cnblogs.com/zhanglitong/p/3206497.html
- vs2017 创建项目推送到Git上
地址 在从本地往云上推送的时候遇到了这样的问题 将分支推送到远程存储库时遇到错误: rejected Updates were rejected because the remote contains ...
- 闰年or平年判断
<script type="text/javascript">var year = prompt("请输入一个年份");if(year!=null) ...
- 45.4.7 序列:USER_SEQUENCES(SEQ)
45.4.7 序列:USER_SEQUENCES(SEQ) 要显示序列的属性,可以查询USER_SEQUENCES 数据字典视图.该视图也能用公有同义词SEQ 进行查询.USER_SEQUENCES ...
- AI 的会议总结(by南大周志华)
原文链接:http://blog.csdn.net/akipeng/article/details/6533897 这个列的更详细:http://www.cvchina.info/2010/08/31 ...