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后和给 ...
随机推荐
- 【cpp】new delete
double *M = new double[2*num]; double *T = new double[2 * num]; double *activeM = new double[2 * num ...
- 【数据库-MySQL on Azure】如何使用 MySQL EntityFramework 组件处理 MYSQL PaaS DB
MySQL Database on Azure 是 Azure 平台上推出的 MySQL 云数据库服务,通过全面兼容 MySQL 协议,为用户提供了一个全托管的性能稳定.可快速部署.高可用.高安全性的 ...
- hihoCoder #1151 : 骨牌覆盖问题·二 (矩阵快速幂,DP)
题意:给一个3*n的矩阵,要求用1*2的骨牌来填满,有多少种方案? 思路: 官网题解用的仍然是矩阵快速幂的方式.复杂度O(logn*83). 这样做需要构造一个23*23的矩阵,这个矩阵自乘n-1次, ...
- UVA 1664 Conquer a New Region (Kruskal,贪心)
题意:在一颗树上要求一个到其他结点容量和最大的点,i,j之前的容量定义为i到j的路径上的最小边容量. 一开始想过由小到大的去分割边,但是很难实现,其实换个顺序就很容易做了,类似kruskal的一个贪心 ...
- 爆零系列—补题A
http://codeforces.com/contest/615/problem/A 读错题 结果发现是无脑题 直接标记统计 #include<cstdio> #include< ...
- Scalatra
SBT和giter8 在你开始着手之前,你需要安装两个工具(我假设你已经安装了JDK1.6+).我将给你提供简缩的安装指令,详细版的安装指令可通过 下面的scalatra页面找到( http://ww ...
- Asp.Net Core 入门(九)—— 环境变量 TagHelper
我们在之前讲Program.cs文件做了什么的时候,提到启动CreaeDefaultBuilder会获取环境变量来做一些判断之类的操作.那么我们的Taghelper也可以使用“ASPNETCORE_E ...
- 关于highchts X时间轴比设置时间相差好几个小时的解决
经过一番查询和研究发现,在曲线图里,x轴的UNIX时间戳是要乘以1000的(通过在线的UNIX转换,结果与原来没有乘以1000的时间戳相差甚远),不然显示的时间会有很大的误差,真是百思不得其解. 另外 ...
- 编写shellcode的几种姿势
今天开始在做hitcon-training的题目,做到lab2就发现了自己的知识盲区,遇到无法执行shell的情况,需要自己打shellcode执行cat flag 操作 经过一系列的搜索,发现了几种 ...
- PAT (Basic Level) Practise (中文)-1032. 挖掘机技术哪家强(20)
PAT (Basic Level) Practise (中文)-1032. 挖掘机技术哪家强(20) http://www.patest.cn/contests/pat-b-practise/1032 ...