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. php关于精准计算的模块 BCMath

    Php: BCMath bc是Binary Calculator的缩写.bc*函数的参数都是操作数加上一个可选的 [int scale],比如string bcadd(string $left_ope ...

  2. SWTError: No more handles [gtk_init_check() failed] running platform tests (on Linux)

    http://www.lemmster.de/2013-12-19-swterror-no-more-handles-gtk_init_check-failed-running-platform-te ...

  3. POJ 2378 Tree Cutting (树的重心,微变形)

    题意: 给定一棵树,n个节点,若删除点v使得剩下的连通快最大都不超过n/2,则称这样的点满足要求.求所有这样的点,若没有这样的点,输出NONE. 思路: 只需要拿“求树的重心”的代码改一行就OK了.因 ...

  4. hihoCoder #1080 : 更为复杂的买卖房屋姿势 (线段树,多tag)

    题意: 有编号为0~n的n+1个房屋,给出每个房屋的起始价格,随后给出m种修改,每次修改都要进行输出所有房屋的价格总和.修改有两种方式:(1)政府调控,编号L~R全置为同一价格(0)房屋自行涨跌,编号 ...

  5. hihoCoder hiho一下 第四十六周 博弈游戏·Nim游戏·三( sg函数 )

    题意: 给出几堆石子数量,每次可以取走一堆中任意数量的石头,也可以将一堆分成两堆,而不取.最后取走者胜. 思路: 先规矩地计算出sg值,再对每个数量查SG值就可以了.最后求异或和.和不为0的就是必赢. ...

  6. springboot上传linux文件无法浏览,提示404错误

    1.配置文件地址置换 @Componentclass WebConfigurer implements WebMvcConfigurer { @Autowired ConfigUtil bootdoC ...

  7. Bootstrap历练实例:禁用的按钮

    <!DOCTYPE html><html><head> <meta http-equiv="Content-Type" content=& ...

  8. shell脚本,计算学生分数的题目。

    1.计算学生平均分数的值是多少? 2.计算每门课都大于80分的学生姓名.3.计算每门课都小于90分的学生姓名.

  9. Spring框架xml配置文件 复杂类型属性注入——数组 list map properties DI dependency injection 依赖注入——属性值的注入依赖于建立的对象(堆空间)

    Person类中的各种属性写法如下: package com.swift.person; import java.util.Arrays; import java.util.List; import ...

  10. ios lazying load

    初步写一些自己对于lazyload的看法吧.这篇文章主要针对普通view,对于image相关的的懒加载,准备过几天研究一下在写. 懒加载,又称为延迟加载.通常用法,你有一个UITextField类型的 ...