Codeforces Round Rockethon 2015
A. Game
题目大意:A有N1个球,B有N2个球,A每次可以扔1-K1个球,B每次可以扔1-K2个球,谁先不能操作谁熟
思路:.....显然每次扔一个球最优....
#include<iostream>
#include<cstdio>
#include <math.h>
#include<algorithm>
#include<string.h>
#include<queue>
#define MOD 10000007
#define maxn 200000
#define LL long long
using namespace std;
int main()
{
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a<=b)printf("Second\n");else printf("First\n");
return ;
}
B. Permutations
题目大意:给你一个1-n的排列p,要你求在f(p)最大的前提下,字典序为m的排列

思路:一开始想烦了...对于1-n-1的排列,新的数n一定是插入n-1的左边或者右边,这样的排列才是满足f(p)最大的,于是写出来就会发现从小到大每一个数字要么放在当前序列的最前面,要么放在当前序列的最后面,然后就没有然后了
#include<iostream>
#include<cstdio>
#include <math.h>
#include<algorithm>
#include<string.h>
#include<queue>
#define MOD 10000007
#define maxn 200000
#define LL long long
using namespace std;
long long bin[];
int visit[maxn],ans[maxn];
int main()
{
bin[]=;
for(int i=;i<=;i++)bin[i]=bin[i-]*2LL;
int n,anss;
long long m;
while(scanf("%d%I64d",&n,&m)!=EOF)
{
int last=n;
for(int i=,j=;i<=n;i++)
{
int u=bin[n-i-];
if(m<=u)ans[j]=i,j++;
else ans[last]=i,last--,m-=u;
}
for(int i=;i<=n;i++)printf("%d ",ans[i]);
}
return ;
}
G1:Inversions problem
题目大意:对于每个1-n的排列,可以进行K次操作,每次操作可以对随机的一段子序列逆向,问K次操作后逆序数的期望是多少?
思路:敲了发暴力过了G1
#include<iostream>
#include<cstdio>
#include <math.h>
#include<algorithm>
#include<string.h>
#include<queue>
#define MOD 10000007
#define maxn 200000
#define LL long long
using namespace std;
int a[],m,n,up=,down=;
void dfs(int kk,int b[])
{
int c[],d[];
memcpy(d,b,sizeof(d));
if(kk==m+)
{
int inv=;
for(int i=;i<=n;i++)
{
for(int j=i+;j<=n;j++)
{
if(b[j]<b[i])inv++;
}
}
up+=inv;down++;
return;
}
for(int i=;i<=n;i++)
for(int j=i;j<=n;j++)
{
for(int k=;k<=j-i+;k++)
{
c[k]=b[j-k+];
}
for(int k=;k<=j-i+;k++)
{
b[i+k-]=c[k];
}
dfs(kk+,b);
for(int k=;k<=j-i+;k++)
{
c[k]=b[j-k+];
}
for(int k=;k<=j-i+;k++)
{
b[i+k-]=c[k];
}
}
}
int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=n;i++)
{
scanf("%d",&a[i]);
}
dfs(,a);
printf("%.9lf",1.0*up/down);
return ;
}
Codeforces Round Rockethon 2015的更多相关文章
- Codeforces Round #366 (Div. 2) ABC
Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
- Codeforces Round #279 (Div. 2) ABCDE
Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems # Name A Team Olympiad standard input/outpu ...
- Codeforces Round #262 (Div. 2) 1003
Codeforces Round #262 (Div. 2) 1003 C. Present time limit per test 2 seconds memory limit per test 2 ...
- Codeforces Round #262 (Div. 2) 1004
Codeforces Round #262 (Div. 2) 1004 D. Little Victor and Set time limit per test 1 second memory lim ...
- Codeforces Round #370 - #379 (Div. 2)
题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi ...
- Codeforces Round #371 (Div. 1)
A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...
随机推荐
- Mybatis配置多数据源
一. Spring配置多数据源 二. Spring配置数据源 三. MultipleDataSource的实现 1: package com.wbl.modal; 2: 3: import org. ...
- 高效vim插件
目录[-] 高效vim插件 插件管理利器 高效插件集 NerdTree snipMate tagbar jedi-vim eclim c.vim vim-colorschemes vim配置 一个实例 ...
- sql service 查询分析数据库
--学会通配符 https://blog.csdn.net/blackfwhite/article/details/80382849 --学会变量中的变量 https://www.cnblogs.co ...
- (一)maven之创建一个maven项目
为什么要使用Maven? 1. maven使用的是本地仓库存储jar,所有项目都会共用仓库中的同一份jar. 2. Spring core.jar必须同时引用版本兼容的common-logging ...
- Kafka-broker配置说明
配置文件在config/server.properties 下面的一些配置可能是你需要进行修改的. broker.id 整数,建议根据ip区分 log.dirs kafka存放消息文件的路径, 默认/ ...
- vue watch 监听
1.普通的watch data() { return { frontPoints: 0 } }, watch: { frontPoints(newValue, oldValue) { console. ...
- 读懂 Deployment YAML【转】
既然要用 YAML 配置文件部署应用,现在就很有必要了解一下 Deployment 的配置格式,其他 Controller(比如 DaemonSet)非常类似. 还是以 nginx-deploymen ...
- Python list 列表和tuple元组
1 list是一种Python的数据类型--列表 list是一种有序的集合,可以进行增删改查 >>>name=[aa,bb,cc] >>>name ['aa','b ...
- javascript基本数据类型问题汇总
isNaN()检测是否是NaN: 比较浮点相等,用绝对值,是否小于某一个阈值 Math.abs(1/3 - (1-2/3))<0.0000001: 字符串多行显示\n,ES6中使用反引号``: ...
- plsql循环的简单实例
declare v_id tbl_regions.regions_id%type; begin .. loop select t.regions_id into v_id from tbl_regio ...