思路: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. HDU5785 manacher+差分数组

    用manacher算法O(n)求出所有的回文半径.有了回文半径后,就可以求出L[i]表示以i结尾的回文串的起始位置的和R[i]表示以i起始的回文串的结尾位置的和,然后就可以求出答案了,这里要注意奇偶长 ...

  2. OpenERP QWeb模板标签笔记

    在OpenERP中,通过QWeb来对模板进行渲染后加载到浏览器中,而模板中有许多的标签来定制各种需求变化,在这里记录学习过程中碰到的标签定义,以方便查询. 模板中的标签统一都是以"t-&qu ...

  3. HTML字符实体

    常用实体符号:

  4. Android入门:绑定本地服务

    一.绑定服务介绍   前面文章中讲过一般的通过startService开启的服务,当访问者关闭时,服务仍然存在: 但是如果存在这样一种情况:访问者需要与服务进行通信,则我们需要将访问者与服务进行绑定: ...

  5. 【服务器防护】WEB防护 - WEBSHELL攻击探测【转载】

    原文:http://www.2cto.com/Article/201511/451757.html 1. 什么是webshell?     基于b/s架构的软件部署在Internet上,那么安全性是必 ...

  6. 根据出生日期计算年龄的sql各种数据库写法

    ORACLE数据库: ) KINGBASE数据库: DB2数据库: TIMESTAMPDIFF(,

  7. xmpp4-总览

    1注意点 创建的聊天室本地缓存,和服务器存储有时不同步,似乎聊过天就更稳定一点.

  8. robot API笔记2

    robot.conf 设计方案 实现设置测试执行和输出处理. 这个方案实现了 RobotSettings 和 RebotSettings 内部使用的类 该框架. 不应该有这些类需要使用外部.这个包可以 ...

  9. Nodejs开发框架Express3.0开发手记–从零开始

    转载请注明出处: http://blog.fens.me/nodejs-express3/ 程序代码已经上传到github有需要的同学,自行下载. https://github.com/bsspiri ...

  10. [bootstrap] 实用的bootstrap模版下载

    https://shapebootstrap.net/ http://shapebootstrap.net/item/1524915-adminlte-dashboard-and-control-pa ...