Codeforces #259 Div.2
A. Little Pony and Crystal Mine
模拟题. 用矩阵直接构造或者直接根据关系输出
B. Little Pony and Sort by Shift
模拟题。
通过提供的操作得到的序列只能是两段递增或者整个序列递增。
那么可以求得第一段递增序列长度为0…p
如果整个序列是递增,即 p= n-1 那么操作次数就是0.
否则,假设是两段递增,把原始的序列恢复出来,设当前序列是AB,那么A就是0…p
BA = (A'B')', '表示对序列进行翻转,
如果BA是有序的,那么需要的操作数就是n-p-1.否则是没法得到,输出-1.
时间复杂度为O(n)
C. Little Pony and Sort by Shift
数学题,快速幂取模
给m个面的骰子扔n次,求期望点数的最大值。
样例很明显,对与一般化情况通过组合数学方法,我们可以得到:
如果最大值为1,1出现的次数只有1.
如果最大值为2,2出现的次数有
如果最大值为3,2出现的次数有
如果最大值为4,2出现的次数有
......
如果最大值为2,2出现的次数有
每一次出现的概率都是
那么期望值就是
化简后可以得到
含幂项可以通过快速幂取模的方法来求,所以总的时间复杂度为O(mlogn)
Codeforces #259 Div.2的更多相关文章
- Codeforces #344 Div.2
Codeforces #344 Div.2 Interview 题目描述:求两个序列的子序列或操作的和的最大值 solution 签到题 时间复杂度:\(O(n^2)\) Print Check 题目 ...
- Codeforces #345 Div.1
Codeforces #345 Div.1 打CF有助于提高做题的正确率. Watchmen 题目描述:求欧拉距离等于曼哈顿距离的点对个数. solution 签到题,其实就是求有多少对点在同一行或同 ...
- Codeforces Beta Round #27 (Codeforces format, Div. 2)
Codeforces Beta Round #27 (Codeforces format, Div. 2) http://codeforces.com/contest/27 A #include< ...
- Codeforces#441 Div.2 四小题
Codeforces#441 Div.2 四小题 链接 A. Trip For Meal 小熊维尼喜欢吃蜂蜜.他每天要在朋友家享用N次蜂蜜 , 朋友A到B家的距离是 a ,A到C家的距离是b ,B到C ...
- codeforces #592(Div.2)
codeforces #592(Div.2) A Pens and Pencils Tomorrow is a difficult day for Polycarp: he has to attend ...
- codeforces #578(Div.2)
codeforces #578(Div.2) A. Hotelier Amugae has a hotel consisting of 1010 rooms. The rooms are number ...
- codeforces #577(Div.2)
codeforces #577(Div.2) A Important Exam A class of students wrote a multiple-choice test. There are ...
- codeforces #332 div 2 D. Spongebob and Squares
http://codeforces.com/contest/599/problem/D 题意:给出总的方格数x,问有多少种不同尺寸的矩形满足题意,输出方案数和长宽(3,5和5,3算两种) 思路:比赛的 ...
- Codeforces Round #259 (Div. 2)AB
链接:http://codeforces.com/contest/454/problem/A A. Little Pony and Crystal Mine time limit per test 1 ...
随机推荐
- PL/SQL 查找1-100之间的素数
--实现查找1-100之间的素数 declare v_no ; --标记是第几个素数 v_number number; --表示1-100之间的数 v_num number; begin .. loo ...
- Web SQL Database实例
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 浅谈OpenGL变换矩阵
OpenGL中使用的矩阵全为列向量为主的矩阵. 参考OpenGL变换网站为 http://www.songho.ca/opengl/gl_transform.html 1.什么是GL_MODELVI ...
- [js]识别浏览器及版本
var userAgent = navigator.userAgent.toLowerCase();window.jQuery.browser = { version: (userAgent.m ...
- 常用vim设置
set tabstop=4set shiftwidth=4set expandtabset hlsearchset cindent set autoindent set tabstop=4是设TAB宽 ...
- com.microsoft.sqlserver.jdbc.SQLServerException: 到主机 的 TCP/IP 连接失败。 java.net.ConnectException: Connection refused: connect
问题描述:最简单的数据库连接报错,到主机 的 TCP/IP 连接失败.(win 7 操作系统) 错误信息: com.microsoft.sqlserver.jdbc.SQLServerExcep ...
- linux在yum下安装mysql
1:查看软件是否安装 yum list installed | grep mysql 2:卸载CentOS系统自带mysql数据库 yum -y remove mysql-libs.x86_64,若有 ...
- Cocos2d-JS 自定义loading界面
[转]http://blog.csdn.net/et_sandy/article/details/41415047 环境: win7 64位 Cocos2d-JS v3.1 Cocos Code ID ...
- 企业好助手U-Mail邮件服务器软件
对于一家企业,最核心的是什么?有人说人才,有人说技术,也有人说是数据(信息),依小编来 看,这些答案都没错,人才会流动,技术在不断更新,唯有数据(信息),日积月累,将沉淀为公司历史的一部分,作为决策的 ...
- linux 无法解压过大文件解决
[root@vmbbak yum]# unzip RHEL_5.7\ x86_64\ DVD-1.zip error: Zip file too big (greater than 429495910 ...