The 2014 ACMICPC Asia Regional Shanghai Online
XorZip小队第一次合作,虽然结果还是有些可惜,但是状态和感觉都还不错。
【A】数论+二分(-_-///)
【B】Lucas定理+数位DP(-_-///)
【C】LCA、LCT+树链剖分
【E】DLX(-_-///)
【G】几何题,线段与椭球的交点
【H】Kuangbin说这是个简单DP(简单...0.0...)矩阵优化
【J】本福特定律(妈蛋,这是个啥?......)
【K】LCT
【D】
Contest
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
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
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 .
0.6 0.3 0.4
0.3 0.7 0.9
【Sample Output】
Case #: 2.20000
【题意】
这是另一个次元的ACM比赛么...0.0...每个队伍N个人,一共M道题,每小时一题,每题限定只能有1人做题,其他人出去玩。给出每个队员对每一道题解出的概率,最后要求计算出一种方案,使得最终的出题数数学期望最大化。
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)
● 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 ?

Each case contains one single non-negative integer, indicating number of “M”s. (0 ≤ N ≤ 1012)
【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)
Each case contains two binary number represents the length L and the width W of given land. (0 < L, W ≤ 21000)
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)
【Sample Output】
Case #:
Case #:
【分析】
The 2014 ACMICPC Asia Regional Shanghai Online的更多相关文章
- The 2014 ACM-ICPC Asia Regional Anshan
继续复盘下一场Regional! [A]-_-/// [B]模拟(之前每次遇到模拟.暴搜都直接跳了,题目太长也是一个原因...下次是在不行可以尝试一下) [C]数论 互质.容斥? [D]数学推导(方差 ...
- The 2014 ACMICPC Asia Regional Xian
2题继续遗憾收场,每次都是只差最后一步.这一场却是之前那么多场中感觉距离奖牌最近的时候.好好总结一下经验教训,复盘之后好好准备下一场北京的最后一战吧. 一开始的状态非常不错,10分钟跟榜完成1A,第二 ...
- The 2014 ACMICPC Asia Regional Guangzhou Online
[A]-_-/// [B]线段树+位运算(感觉可出) [C]地图BFS,找最长线 [D]地图BFS,加上各种复杂情况的最短路-_- [E]-_-/// [F]三分+圆与线段的交点,计算几何 [G]-_ ...
- The 2014 ACMICPC Asia Regional Beijing Online
[A]极角排序+树状数组 [B]计算几何,凸包(队友已出) [C]-_-///不懂 [D]数论,概率密度 [E]图的连通性+Floyed传递闭包+bitset [F]贪心 [G]签到题 [H]区间维护 ...
- The 2014 ACMICPC Asia Regional Xian Online
[A]签到题 [B]后缀数组 [C]染色,DP(感觉可出) [D]BFS搜索,有点麻烦 [E]博弈论,Nim博弈 [F]BFS状态搜索 [G]概率DP+状态压缩 [H]异或+构造 [I]矩阵快速幂(队 ...
- The 2014 ACM-ICPC Asia Regional Anshan Online
[A]无向图的双联通子图计数.DP+状态压缩 [B]计算几何(点的旋转) [C]DP+状态压缩 [D]离散数学+DP (感觉可出) [E]概率DP [F]LCT模板题(-_-///LCT是啥!!!!) ...
- 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 ...
- 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 ...
- The 2014 ACM-ICPC Asia Mudanjiang Regional Contest(2014牡丹江区域赛)
The 2014 ACM-ICPC Asia Mudanjiang Regional Contest 题目链接 没去现场.做的网络同步赛.感觉还能够,搞了6题 A:这是签到题,对于A堆除掉.假设没剩余 ...
随机推荐
- vi 使用教程
编辑一个文本文件是经常使用到的计算机操作.我们想做的大多数事情都需要使用某种文件编辑.文本编辑器会方便文件的创建和修改.编辑一个文本文件是经常使用到的计算机操作.我们想做的大多数事情都需要使用某种文件 ...
- 在调试安卓系统的时候需要这个 ”adb disable-verity“
在调试设备的时候.想要对文件进行读写 于是使用adb remount 出现提示. 请使用 ”adb disable-verity“ 于是使用adb disable-verity 的命令. 得到如下 ...
- Android sdk content loader
方法一(关闭后重启): 遇到Eclipse右下角一直显示“Android sdk content loader 0%”的情况时,直接关掉Eclipse,有ADB进程在运行时通过进程管理器结束进程,然后 ...
- WordPress 邮箱防抓取
现在网络上有很多爬虫,专门四处搜集网站代码中出现的邮箱,搜集到了之后就批量出售或者发送垃圾邮件.很多人都把邮箱中的 “@” 换成 “#”,但这样对用户不太方便,而且这种方法很多机器人都可以识破,同样被 ...
- TCPIP header
tcp packet: tcp header: ip header:
- UIGestureRecognizer 手势浅析
目录[-] iOS开发中的手势体系——UIGestureRecognizer分析及其子类的使用 一.引言 二.手势的抽象类——UIGestureRecognizer 1.统一的初始化方法 2.手势状态 ...
- 根据key存不存在查询json
select * from table where value->'key' != 'null';
- 转载 Deep learning:六(regularized logistic回归练习)
前言: 在上一讲Deep learning:五(regularized线性回归练习)中已经介绍了regularization项在线性回归问题中的应用,这节主要是练习regularization项在lo ...
- UVA - 1347 Tour(DP + 双调旅行商问题)
题意:给出按照x坐标排序的n个点,让我们求出从最左端点到最右短点然后再回来,并且经过所有点且只经过一次的最短路径. 分析:这个题目刘汝佳的算法书上也有详解(就在基础dp那一段),具体思路如下:按照题目 ...
- ubuntu服务器移植步骤
1.安装LAMP套件 1 tasksel 2.安装FTP工具 http://www.cnblogs.com/esin/p/3483646.html 3.安装PHPMyAdmin 1)安装 1 apt- ...