🔺 Garbage Remembering Exam UVA - 11637()
其中 x为当前单词的左右距离为k的单词的个数, 分子是把一排单词中一个单词的有效距离的单词取出来全排列到环形的无效距离内,然后剩余的单词全排列;
考虑到排列与组合数据过大,用 exp()函数,其中log(N!)=log(N)+log(N-1)+...+log(1);
需要注意 用long double能过。。。
代码如下:
没大弄明白为什么n-1-x < 2*k 的时候不考虑
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 100005
long double temp[N];
int n,k;
double solve()
{
if(n==) return ;//只有一个单词,无效为0
else if(*k+>=n) return n;//如果圈中的一个单词从左边或右边距离都小于K,则该单词无效,所有单词等效
double ret=;
for(int i=;i<=n;i++)
{
int x=min(k,i-)+min(k,n-i);//一个单词左右k范围内的单词个数
if(n--x-*k>=)
{
ret+=exp(temp[n--x]+temp[n--*k]-temp[n-]-temp[n--x-*k]);
}
// else
// ret += exp(temp[2*k] - temp[2*k-n+1+x] + temp[x] - temp[n-1]);
}
return n-ret;
}
int main()
{
temp[]=;
for(int i=;i<N;i++)
temp[i]=temp[i-]+log((long double)i);
int cas=;
while(scanf("%d%d",&n,&k))
{
if(n==&&k==) break;
printf("Case %d: %.4lf\n",cas++,solve());
}
return ;
}
🔺 Garbage Remembering Exam UVA - 11637()的更多相关文章
- UVA - 11637 Garbage Remembering Exam (组合+可能性)
Little Tim is now a graduate,and is thinking about higher studies. However, he first needs to appear ...
- uva 11673 Garbage Remembering Exam (概率)
题目链接: http://vjudge.net/problem/viewProblem.action?id=42000 该过程为随即过程,因此总期望值等于个单词对应的期望值,即它们wasted的概率 ...
- UVA 11637 Garbage Remembering Exam
#include <iostream> #include <stdio.h> #include <cstring> #include <math.h> ...
- UVa 156 (映射 map)
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- 训练指南 UVA - 11419(二分图最小覆盖数)
layout: post title: 训练指南 UVA - 11419(二分图最小覆盖数) author: "luowentaoaa" catalog: true mathjax ...
- 训练指南 UVA - 11383(KM算法的应用 lx+ly >=w(x,y))
layout: post title: 训练指南 UVA - 11383(KM算法的应用 lx+ly >=w(x,y)) author: "luowentaoaa" cata ...
- 训练指南 UVA - 11354(最小生成树 + 倍增LCA)
layout: post title: 训练指南 UVA - 11354(最小生成树 + 倍增LCA) author: "luowentaoaa" catalog: true ma ...
- 训练指南 UVA - 11478(最短路BellmanFord+ 二分+ 差分约束)
layout: post title: 训练指南 UVA - 11478(最短路BellmanFord+ 二分+ 差分约束) author: "luowentaoaa" catal ...
- 训练指南 UVA - 11090(最短路BellmanFord+ 二分判负环)
layout: post title: 训练指南 UVA - 11090(最短路BellmanFord+ 二分判负环) author: "luowentaoaa" catalog: ...
随机推荐
- 【BZOJ4698】[SDOI2008]Sandy的卡片
[BZOJ4698][SDOI2008]Sandy的卡片 题面 flag倒了. bzoj 洛谷 题解 首先题目的区间加很丑对吧, 将每个串差分一下,就可以转化为 求: 给定\(N\)个串,求他们的最长 ...
- WPF RegisterAttached ListBoxItem(附加属性传递到Item)
/// <summary> /// Controls的附加属性 /// </summary> public class ControlsAttached : Dependenc ...
- python爬虫:爬取慕课网视频
前段时间安装了一个慕课网app,发现不用注册就可以在线看其中的视频,就有了想爬取其中的视频,用来在电脑上学习.决定花两天时间用学了一段时间的python做一做.(我的新书<Python爬虫开发与 ...
- python接口自动化1-发送get请求 前言
前言 requests模块,也就是老污龟,为啥叫它老污龟呢,因为这个官网上的logo就是这只污龟,接下来就是学习它了. 一.环境安装 1.用pip安装requests模块 >>pip in ...
- 【MySQL 数据库】MySQL目录
目录 [第一章]MySQL数据概述 [第二章]MySQL数据库基于Centos7.3-部署 [MySQL解惑笔记]Centos7下卸载彻底MySQL数据库 [MySQL解惑笔记]忘记MySQL数据库密 ...
- 【Linux 运维】 date的使用
date的使用 一.常用时间格式 #年.月.日 四位年大写,其余小写 [root@localhost ~]# date +%Y #长格式显示四位数年 [root@localhost ~]# date ...
- 论文笔记:DeepFace: Closing the Gap to Human-Level Performance in Face Verification
2014 CVPR Facebook AI研究院 简单介绍 人脸识别中,通常经过四个步骤,检测,对齐(校正),表示,分类 论文主要阐述了在对齐和表示这两个步骤上提出了新的方法,模型的表现超越了前人的工 ...
- [转]如何设计自适应屏幕大小的网页 Responsive Web Design
随着3G的普及,越来越多的人使用手机上网. 移动设备正超过桌面设备,成为访问互联网的最常见终端.于是,网页设计师不得不面对一个难题:如何才能在不同大小的设备上呈现同样的网页? 手机的屏幕比较小,宽度通 ...
- Live Love(思维)
DreamGrid is playing the music game Live Love. He has just finished a song consisting of n notes and ...
- 软工 · BETA 版冲刺前准备(团队)
软工 · BETA 版冲刺前准备(团队) 过去存在的问题 组员之间缺乏沟通,前后端缺乏沟通协作 组员积极性不高 基础知识不够扎实 手动整合代码效率过低 我们已经做了哪些调整/改进 通过会议加强组员之间 ...