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的更多相关文章

  1. 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 ...

  2. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  3. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  4. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

  5. Codeforces Round #279 (Div. 2) ABCDE

    Codeforces Round #279 (Div. 2) 做得我都变绿了! Problems     # Name     A Team Olympiad standard input/outpu ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #370 - #379 (Div. 2)

    题意: 思路: Codeforces Round #370(Solved: 4 out of 5) A - Memory and Crow 题意:有一个序列,然后对每一个进行ai = bi - bi  ...

  9. Codeforces Round #371 (Div. 1)

    A: 题目大意: 在一个multiset中要求支持3种操作: 1.增加一个数 2.删去一个数 3.给出一个01序列,问multiset中有多少这样的数,把它的十进制表示中的奇数改成1,偶数改成0后和给 ...

随机推荐

  1. android Random的使用

    一.Random 此类的实例用于生成伪随机数流.此类使用 48 位的种子,使用线性同余公式 (linear congruential form) 对其进行了修改. 如果用相同的种子创建两个 Rando ...

  2. 压力测试工具segie的使用

    压力测试工具segie的使用 使用文档参考地址:https://www.joedog.org/siege-manual/ siege4地址:http://download.joedog.org/sie ...

  3. 刷新本地DNS缓存的方法

    http://www.cnblogs.com/rubylouvre/archive/2012/08/31/2665859.html 常有人问到域名解析了不是即时生效的嘛,怎么还是原来的呢?答案就是在本 ...

  4. python一周速成学习笔记

    目录 一:语法元素 1.注释,变量,空格的使用 2.输入函数,输出函数 3.分支语句,循环语句 4.保留字in,同步赋值 5.import与def以及turtle库 6.eval函数与repr函数 二 ...

  5. Solr版本安装部署指南

    一.依赖包 1.  JDK 1.6以上 2.  solr-4.3.0.tgz 3.  Tomcat或者jetty(注意,solr包中本身就含有jetty的启动相关内容):apache-tomcat-7 ...

  6. 1.JOIN和UNION区别

    1.JOIN和UNION区别join 是两张表做交连后里面条件相同的部分记录产生一个记录集,union是产生的两个记录集(字段要一样的)并在一起,成为一个新的记录集 . JOIN用于按照ON条件联接两 ...

  7. App Store中的开源游戏汇总

    这是国外达人收集的曾经在app store上出现过,或者还在app store上卖的iOS开源游戏的列表,其中代码大部分人你托管在google code或者github上,其中有很多使用Cocos2D ...

  8. Airbnb:别抵制我,宝宝要过 10 岁生日

    今日导读 喜欢旅游的你,一定听说或使用过 airbnb(爱彼迎),在出发前打开它,总是能通过它开始一段奇妙的旅行.可是最近,就在这个打着“共享家”概念的服务型网站正迎来十周年之际,它却遭到了很多国家的 ...

  9. java在线聊天项目0.5版 解决客户端向服务器端发送信息时只能发送一次问题 OutputStreamWriter DataOutputStream socket.getOutputStream()

    没有解决问题之前客户端代码: package com.swift; import java.awt.BorderLayout; import java.awt.Color; import java.a ...

  10. ios之NSURLRequest&NSURLConnection

    网络编程中一般都是经过  请求--->连接--->响应   (request  -->  connection  -->  response)这个过程. 一般的步骤是这样的: ...