XorZip小队第一次合作,虽然结果还是有些可惜,但是状态和感觉都还不错。

【A】数论+二分(-_-///)

【B】Lucas定理+数位DP(-_-///)

【C】LCA、LCT+树链剖分

【D】题目分解成DP+状态压缩

【E】DLX(-_-///)

【F】推算公式+大数

【G】几何题,线段与椭球的交点

【H】Kuangbin说这是个简单DP(简单...0.0...)矩阵优化

【I】GCD+大数

【J】本福特定律(妈蛋,这是个啥?......)

【K】LCT

【L】签到题

【D】

Contest

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

【Problem Description】
   In the ACM International Collegiate Programming Contest, each team consist of three students. And the teams are given 5 hours to solve between 8 and 12 programming problems.
   On Mars, there is programming contest, too. Each team consist of N students. The teams are given M hours to solve M programming problems. Each team can use only one computer, but they can’t cooperate to solve a problem. At the beginning of the ith hour, they will get the ith programming problem. They must choose a student to solve this problem and others go out to have a rest. The chosen student will spend an hour time to program this problem. At the end of this hour, he must submit his program. This program is then run on test data and can’t modify any more.
   Now, you have to help a team to find a strategy to maximize the expected number of correctly solved problems.
   For each problem, each student has a certain probability that correct solve. If the ith student solve the jth problem, the probability of correct solve is Pij .
   At any time, the different between any two students’ programming time is not more than 1 hour. For example, if there are 3 students and there are 5 problems. The strategy {1,2,3,1,2}, {1,3,2,2,3} or {2,1,3,3,1} are all legal. But {1,1,3,2,3},{3,1,3,1,2} and {1,2,3,1,1} are all illegal.
   You should find a strategy to maximize the expected number of correctly solved problems, if you have know all probability
 
【Input】
   The first line of the input is T (1 ≤ T ≤ 20), which stands for the number of test cases you need to solve.
   The first line of each case contains two integers N ,M (1 ≤ N ≤ 10,1 ≤ M ≤ 1000),denoting the number of students and programming problem, respectively.
   The next N lines, each lines contains M real numbers between 0 and 1 , the jth number in the ith line is Pij .
 
【Output】
   For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then a single real number means the maximal expected number of correctly solved problems if this team follow the best strategy, to five digits after the decimal point. Look at the output for sample input for details.
 
【Sample Input】

0.6 0.3 0.4
0.3 0.7 0.9

【Sample Output】

Case #: 2.20000

【题意】

这是另一个次元的ACM比赛么...0.0...每个队伍N个人,一共M道题,每小时一题,每题限定只能有1人做题,其他人出去玩。给出每个队员对每一道题解出的概率,最后要求计算出一种方案,使得最终的出题数数学期望最大化。

 
【分析】
初看感觉是个贪心啊,但是文中有一句当时困扰了比赛N多队伍的描述:
At any time, the different between any two students’ programming time is not more than 1 hour.
后面还有个让人摸不着头脑的sample,顿时好多童鞋表示看不懂。
额,这句话的意思是队伍中所有成员的做题数必须平均,不能出现一名队员比另外一名队员多做1题以上的情况,简单地说就是必须要等所有成员都做过1题之后,才能有人继续做第2个题。
 
这样思路就不难想出来了:
N的上限是10,则把M按照N个一组分开,每一组都要求每个人选择一题,使得总和最大。相当于一个N*N的矩阵,每行每列取一个数使得总和最大。
 
想明白之后顺手直接分组,DFS搜了一遍交上去,果然TLE。于是明白了,这个要用状态压缩的DP来解。
对于每一组:
 f(i,j)表示第i题,j状态时达到的最大和,j用一个最大为2^10的数来表示每个人在当前组是否有做过题目的状态
则:
f(i,j)=max{f(i-,j-<<k)+a[k][i]} j&(<<k)==(<<k)

想明白方程之后就是分组细节上的处理了。

 /* ***********************************************
MYID : Chen Fan
LANG : G++
PROG : D1004
************************************************ */ #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm> using namespace std; int po[]={,,,,,,,,,,,};
double a[][];
bool flag[];
double f[][];
int n; double doit(int l,int r,double sum)
{
memset(f,,sizeof(f));
for (int i=;i<=r-l+;i++)
for (int j=;j<=po[n]-;j++)
{
double temp=;
for (int k=;k<n;k++)
if (((<<k)&j-(<<k))==)
if (temp<f[i-][j-(<<k)]+a[k+][l+i-]) temp=f[i-][j-(<<k)]+a[k+][l+i-];
f[i][j]=temp;
} return f[r-l+][po[n]-];
} int main()
{
int t;
scanf("%d",&t);
for (int tt=;tt<=t;tt++)
{
int m;
scanf("%d%d",&n,&m);
for (int i=;i<=n;i++)
for (int j=;j<=m;j++) scanf("%lf",&a[i][j]); double ans=;
int t1=m/n;
for (int i=;i<=t1;i++)
{
double temp=doit((i-)*n+,i*n,);
ans+=temp;
}
double temp=doit(t1*n+,m,);
ans+=temp; printf("Case #%d: %.5f\n",tt,ans);
}
return ;
}

【启发】

有些题目可能局部是满足DP性质的,可以分解一下再做DP。

【F】

Sawtooth

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

【Problem Description】
   Think about a plane:
   ● One straight line can divide a plane into two regions.    ● Two lines can divide a plane into at most four regions.    ● Three lines can divide a plane into at most seven regions.    ● And so on...
   Now we have some figure constructed with two parallel rays in the same direction, joined by two straight segments. It looks like a character “M”. You are given N such “M”s. What is the maximum number of regions that these “M”s can divide a plane ?
 
【Input】
   The first line of the input is T (1 ≤ T ≤ 100000), which stands for the number of test cases you need to solve.
   Each case contains one single non-negative integer, indicating number of “M”s. (0 ≤ N ≤ 1012)
 
【Output】
   For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then an integer that is the maximum number of regions N the “M” figures can divide.
 
【Sample Input】

【Sample Output】

Case #:
Case #:

【题意】
在平面上摆上M,摆上一个的时候能把平面分成2个部分,摆上2个的时候能分成19个部分,求摆上n个的时候能分成多少个部分。

【分析】

这样的题目首先能想到的肯定是通过公式推算完成,但是由两组数据还很难推出公式,于是我们艰难地画出了第三个M,最后数出来是52。

经过一番艰难地推算,算出来了公式是ans=8n^2-7n+1。

开始感觉估算出来long long是足够大的,交了一次没过,以为是公式问题,,,后来才发现10^12平方之后早就爆了64位了,于是转用大数。

比赛时用了JAVA,TLE,然后之前又没有自己准备C的大数模板,悲剧收场...

【JAVA】

队友整理了个好用的JAVA模板,这玩意以前还不怎么会,经过这次之后应该是没问题了。

 /* ***********************************************
MYID : Chen Fan
LANG : JAVA
PROG : HDU5047
************************************************ */ import java.io.*;
import java.math.BigInteger;
import java.util.*; public class Main
{
static PrintWriter out=new PrintWriter(new BufferedWriter(
new OutputStreamWriter(System.out))); public static void main(String[] args) throws IOException
{
Scan scan=new Scan(); int t=scan.nextInt();
for (int tt=1;tt<=t;tt++)
{
String s=scan.next();
BigInteger a=new BigInteger(s);
a=a.multiply(BigInteger.valueOf(8)).multiply(a).subtract(a.multiply(BigInteger.valueOf(7))).add(BigInteger.valueOf(1));
out.printf("Case #%d: ",tt);
out.println(a);
} out.flush();
}
} class Scan
{
BufferedReader buffer;
StringTokenizer tok; Scan()
{
buffer=new BufferedReader(new InputStreamReader(System.in));
} boolean hasNext()
{
while (tok==null||!tok.hasMoreElements())
{
try
{
tok=new StringTokenizer(buffer.readLine());
} catch (Exception e)
{
return false;
}
}
return true;
} String next()
{
if (hasNext()) return tok.nextToken();
return null;
} int nextInt()
{
return Integer.parseInt(next());
}
}

【不用JAVA】
其实最终的结果没有超出long long太多,当时比赛的时候脑子没转过来,用两个long long的变量把结果分成两部分完全就能存下来了-_-////哭死,这个思路就是简化版的大数操作。

【I】

Divided Land

Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

【Problem Description】
   It’s time to fight the local despots and redistribute the land. There is a rectangular piece of land granted from the government, whose length and width are both in binary form. As the mayor, you must segment the land into multiple squares of equal size for the villagers. What are required is there must be no any waste and each single segmented square land has as large area as possible. The width of the segmented square land is also binary.
 
【Input】
   The first line of the input is T (1 ≤ T ≤ 100), which stands for the number of test cases you need to solve.
   Each case contains two binary number represents the length L and the width W of given land. (0 < L, W ≤ 21000)
 
【Output】
   For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then one number means the largest width of land that can be divided from input data. And it will be show in binary. Do not have any useless number or space.
 
【Sample Input】
3
10 100
100 110
10010 1100

【Sample Output】

Case #1: 10
Case #2: 10
Case #3: 110

【题意】
给出一块平面,要求使用一些正方形去摆满,求最大正方形的边长。

【分析】

首先要想到正方形分矩形的最大边长是其长和宽的最大公约数。

然后就是计算二进制(大数)的最大公约数的问题了。

很不好意思的是,JAVA中也是直接有模板可以套用的,而且借由快速的输入输出模板,题目变得so easy了。

 /* ***********************************************
MYID : Chen Fan
LANG : JAVA
PROG : HDU5050
************************************************ */ import java.io.*;
import java.math.BigInteger;
import java.util.*; public class Main
{
static PrintWriter out=new PrintWriter(new BufferedWriter(
new OutputStreamWriter(System.out))); public static void main(String[] args) throws IOException
{
Scan scan=new Scan(); int t=scan.nextInt(); for (int tt=1;tt<=t;tt++)
{
String s=scan.next();
BigInteger a=new BigInteger(s,2);
s=scan.next();
BigInteger b=new BigInteger(s,2);
out.printf("Case #%d: ",tt);
out.println(a.gcd(b).toString(2));
} out.flush();
}
} class Scan
{ BufferedReader buffer;
StringTokenizer tok; Scan()
{
buffer=new BufferedReader(new InputStreamReader(System.in));
} boolean hasNext()
{
while (tok==null||!tok.hasMoreElements())
{
try
{
tok=new StringTokenizer(buffer.readLine());
} catch (Exception e)
{
return false;
}
}
return true;
} String next()
{
if (hasNext()) return tok.nextToken();
return null;
}
int nextInt()
{
return Integer.parseInt(next());
}
}

【L】

the Sum of Cube

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

【Problem Description】
A range is given, the begin and the end are both integers. You should sum the cube of all the integers in the range.
 
【Input】
The first line of the input is T(1 <= T <= 1000), which stands for the number of test cases you need to solve. Each case of input is a pair of integer A,B(0 < A <= B <= 10000),representing the range[A,B].
 
【Output】
For each test case, print a line “Case #t: ”(without quotes, t means the index of the test case) at the beginning. Then output the answer – sum the cube of all the integers in the range.
 
【Sample Input】

【Sample Output】

Case #:
Case #:

【分析】

求a~b的立方和,防止爆零。

The 2014 ACMICPC Asia Regional Shanghai Online的更多相关文章

  1. The 2014 ACM-ICPC Asia Regional Anshan

    继续复盘下一场Regional! [A]-_-/// [B]模拟(之前每次遇到模拟.暴搜都直接跳了,题目太长也是一个原因...下次是在不行可以尝试一下) [C]数论 互质.容斥? [D]数学推导(方差 ...

  2. The 2014 ACMICPC Asia Regional Xian

    2题继续遗憾收场,每次都是只差最后一步.这一场却是之前那么多场中感觉距离奖牌最近的时候.好好总结一下经验教训,复盘之后好好准备下一场北京的最后一战吧. 一开始的状态非常不错,10分钟跟榜完成1A,第二 ...

  3. The 2014 ACMICPC Asia Regional Guangzhou Online

    [A]-_-/// [B]线段树+位运算(感觉可出) [C]地图BFS,找最长线 [D]地图BFS,加上各种复杂情况的最短路-_- [E]-_-/// [F]三分+圆与线段的交点,计算几何 [G]-_ ...

  4. The 2014 ACMICPC Asia Regional Beijing Online

    [A]极角排序+树状数组 [B]计算几何,凸包(队友已出) [C]-_-///不懂 [D]数论,概率密度 [E]图的连通性+Floyed传递闭包+bitset [F]贪心 [G]签到题 [H]区间维护 ...

  5. The 2014 ACMICPC Asia Regional Xian Online

    [A]签到题 [B]后缀数组 [C]染色,DP(感觉可出) [D]BFS搜索,有点麻烦 [E]博弈论,Nim博弈 [F]BFS状态搜索 [G]概率DP+状态压缩 [H]异或+构造 [I]矩阵快速幂(队 ...

  6. The 2014 ACM-ICPC Asia Regional Anshan Online

    [A]无向图的双联通子图计数.DP+状态压缩 [B]计算几何(点的旋转) [C]DP+状态压缩 [D]离散数学+DP (感觉可出) [E]概率DP [F]LCT模板题(-_-///LCT是啥!!!!) ...

  7. ZOJ 3811 Untrusted Patrol The 2014 ACM-ICPC Asia Mudanjiang Regional First Round

    Description Edward is a rich man. He owns a large factory for health drink production. As a matter o ...

  8. The 2014 ACM-ICPC Asia Mudanjiang Regional Contest

    The 2014 ACM-ICPC Asia Mudanjiang Regional Contest A.Average Score B.Building Fire Stations C.Card G ...

  9. The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)

    The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...

随机推荐

  1. Redis如何保存数组和对象

    个人建议使用PHP自带的序列化函数serialize和unserialize函数 我们可以封装一个自己的Redis类 <?php class MyRedis{ private static $h ...

  2. 2016 ccpc 杭州赛区的总结

    毕竟是在杭电比的,和之前大连的icpc不同,杭电毕竟是隔壁学校,来回吃住全都是在自家寝室,方便! 不过说到方便也是有点不方便,室友都喜欢玩游戏,即使我昨晚9.30就睡觉了,仍然是凌晨一点才睡着,233 ...

  3. su -无反应

    一.问题产生环境 CentOS 6.3 X64SecureCRT 7.0.0 英文版 二.问题具体描述 今天操作自己的一台Linux服务器时,突然su命令不好使了,敲入命令回车后,没有任何反应,不管是 ...

  4. Androidndk开发打包时我们应该如何注意平台的兼容(x86,arm,arm-v7a)

    很多朋友在开发Android JNI的的时候,会遇到findlibrary returned null的错误,因为某种原因,so没有打包到apk中.下面浅析下引起该错误的原因以及平台兼容性问题. 一. ...

  5. openCV(二)---iOS中使用openCV的图片格式转换

    可以实现将UIImage和IplImage类型实现相互转换 //由于OpenCV主要针对的是计算机视觉方面的处理,因此在函数库中,最重要的结构体是IplImage结构. - (IplImage *)C ...

  6. C#窗口实现最小化到系统托盘

    using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...

  7. Validation of viewstate MAC failed machinekey生成、使用方法

    前段时间公司为了减轻服务器压力,对网页做了集群,分布在多台服务器,通过DNS轮回解析到各台服务器,结果页面只要打开停留到DNS解析到下一个地址,就会出现出下错误信息. Validation of vi ...

  8. java设计模式案例详解:工厂模式

    1.简单工厂模式 在不考虑扩展的情况下还是很好用的,其实我们写代码也很经常用到,其主要理解在于传入不同参数则构建不同对象,只有一个工厂,如需添加产品涉及到扩展需要修改比较多的东西,不符合开闭原则,如下 ...

  9. Spring Boot 系列教程3-MyBatis

    MyBatis MyBatis 本是apache的一个开源项目iBatis, 2010年这个项目由apache 迁移到了google code,并且改名为MyBatis .2013年11月迁移到Git ...

  10. Android中实现滑动翻页—使用ViewFlipper(dp和px之间进行转换)

    Android中实现滑动翻页—使用ViewFlipper(dp和px之间进行转换) Android中dp和px之间进行转换 在xml布局文件中,我们既可以设置px,也可以设置dp(或者dip).一般情 ...