思路:dp[i][now][mark][len]   i 表示当前第i 次now存的是后8位,mark为第9位为0还是1 len第九位往高位还有几位和第9位相等。  只存后8位的原因:操作只有200次每次都为加法的话后8位可以表示,如果为乘法第八位已知再加上第九位 和往前的长度已知,所以可以表示所有状态。

所存在问题就是 10 1111 1111 此时加上1之后 会变成 11 0000 0000 但这样并处影响结果 如果之后操作都为加法,只有200次,他不可能影响到前面的1, 乘法相当于左移也不会影响。所以前面的1 不可能作为答案。

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include <iostream>
using namespace std;
double d[][][][];
int a[];
int main() {
int x, k, p, h = ;
memset(d, , sizeof(d));
memset(a, , sizeof(a));
scanf("%d%d%d", &x, &k, &p);
while (x) {
a[h++] = x %;
x /= ;
}
int now = ;
for (int i = ; i < ; ++i)
if (a[i])
now += ( << i); if (h < ) {
d[][now][][] = ;
} else {
int cnt = ;
for (int i = ; i < h; ++i) {
if (a[i] != a[i - ])
break;
cnt++;
}
d[][now][a[]][cnt] = ;
}
for (int i = ; i < k; ++i) {
for (int j = ; j <= ; ++j) {
for (int x = ; x <= ; ++x) {
if (j != ) {
d[i + ][j + ][][x] += d[i][j][][x] * ( - p) / 100.0;
d[i + ][j + ][][x] += d[i][j][][x] * ( - p) / 100.0;
} else {
d[i + ][][][x] += d[i][j][][x] * ( - p) / 100.0;
d[i + ][][][] += d[i][j][][x] * ( - p) / 100.0;
} if (j & ( << )) {
d[i + ][(j << ) % ][][] += d[i][j][][x] * p / 100.0;
d[i + ][(j << ) % ][][x + ] += d[i][j][][x] * p
/ 100.0;
} else {
d[i + ][(j << ) % ][][] += d[i][j][][x] * p / 100.0;
d[i + ][(j << ) % ][][x + ] += d[i][j][][x] * p
/ 100.0;
}
}
}
}
double sum=;
for(int i=;i<;++i)
{
for(int j=;j<;++j)
for(int x=;x<=;++x)
{
int now=i;
int cnt=;
while(now%==)
{
cnt++;
now/=;
}
sum+=d[k][i][j][x]*cnt;
}
}
for(int x=;x<=;++x)
sum+=d[k][][][x]*;
for(int x=;x<=;++x)
sum+=d[k][][][x]*(x+);
printf("%.10lf\n",sum); return ;
}

CodeForces 441E(Codeforces Round #252 (Div. 2))的更多相关文章

  1. Codeforces Round 252 (Div. 2)

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

  2. Codeforces Round #252 (Div. 2) B. Valera and Fruits(模拟)

    B. Valera and Fruits time limit per test 1 second memory limit per test 256 megabytes input standard ...

  3. Codeforces Round #252 (Div. 2) D

    http://codeforces.com/problemset/problem/441/D 置换群的基本问题,一个轮换内交换成正常顺序需要k-1次,k为轮换内元素个数 两个轮换之间交换元素,可以把两 ...

  4. codeforces Round #252 (Div. 2) C - Valera and Tubes

    贪心算法,每条路径最短2格,故前k-1步每次走2格,最后一步全走完 由于数据比较小,可以先打表 #include <iostream> #include <vector> #i ...

  5. Codeforces Round #252 (Div. 2) B. Valera and Fruits

    #include <iostream> #include <vector> #include <algorithm> #include <map> us ...

  6. Codeforces Round #252 (Div. 2) A - Valera and Antique Items

    水题 #include <iostream> #include <set> #include <vector> #include <algorithm> ...

  7. Codeforces Round #252 (Div. 2) 441B. Valera and Fruits

    英语不好就是坑啊.这道题把我坑残了啊.5次WA一次被HACK.第二题得分就比第一题高10分啊. 以后一定要加强英语的学习,要不然就跪了. 题意:有一个果园里有非常多树,上面有非常多果实,为了不然成熟的 ...

  8. Codeforces Round #252 (Div. 2)-C,D

    C题就是一个简单的模拟.首先给每一个人两个.然后把剩下的都给一个人就好了. 给的时候蛇形给. #include<stdio.h> #include<string.h> #inc ...

  9. 【Codeforces AIM Tech Round 4 (Div. 2) C】

    ·将排序限制于子序列中,又可以说明什么呢? C. Sorting by Subsequences ·英文题,述大意:       输入一个长度为n的无重复元素的序列{a1,a2……an}(1<= ...

随机推荐

  1. Java JDBC连接数据库 Access连接数据库

    1.加载JDBC驱动程序:  在连接数据库之前,首先要加载想要连接的数据库的驱动到JVM(Java虚拟机),再通过java.lang.Class类的静态方法forName(String  classN ...

  2. 省市县distpicker的使用

    下载地址https://github.com/fengyuanchen/distpicker 1.引入 <!-- 引入地址 begin --> <script type=" ...

  3. D3.js 坐标轴

    坐标轴,是可视化图表中经常出现的一种图形,由一些列线段和刻度组成.坐标轴在 SVG 中是没有现成的图形元素的,需要用其他的元素组合构成. D3 提供了坐标轴的组件,如此在 SVG 画布中绘制坐标轴变得 ...

  4. Struts2文件上传

    1  在Struts2中上传文件需要 commons-fileupload-1.2.1.jar.commons-io-1.3.2.jar 这两个包. 2  确认页面form表单上的提交方式为POST, ...

  5. C#实现文件下载

    1,Http 协议中有专门的指令来告知浏览器, 本次响应的是一个需要下载的文件. 格式如下:Content-Disposition: attachment;filename=filename.ext以 ...

  6. 2016最全的web前端面试题及答案整理

    面试web前端开发,不管是笔试还是面试,都会涉及到各种专业技术问题,今天小编整理了一些常见的web前端面试题及答案,希望对大家有所帮助. 1.常用那几种浏览器测试?有哪些内核(Layout Engin ...

  7. commonJS — 全局操作(for Window)

    for Window github: https://github.com/laixiangran/commonJS/blob/master/src/forWindow.js 代码 /** * Cre ...

  8. static final的理解

    static: static静态,可以修饰类,成员变量,成员方法,代码块.static修饰的成员变量和方法独立于该类的任何对象,也就是被类的所有成员共享,这要这个类被加载,虚拟机就能根据类名在运行时数 ...

  9. 比对工具之 BWA 使用方法

    BWA算法简介: BWA-bactrack BWA-SW BWA-MEM BWA安装: # installing BWA .tar.bz2 -C /opt/biosoft/ cd /opt/bioso ...

  10. listview定位到上次显示的位置

    整体思路:滑动lictview时,记录listview的位置,定位时定位到该位置. 1.添加全局变量 private int scrolledX = 0; private int scrolledY ...