ZOJ Monthly, November 2014
做了一次月赛,没想到这么难,加上后来补上的题目也只有3个题。第一名也只有4个题啊啊啊啊~.其中两道还是水题。留坑慢慢补上来。

给定如图所示有盖圆柱体,R,H,水面高度h,倾角a,求水得体积。
分析:明显的数值积分题,这样考虑。圆下底面即A点与地面高度lim1, 圆上底面一点B与地面高度lim2,h所处的范围进行讨论从而确定积分几何体的两边的高度。我们积分的几何体应该是一个圆柱体被削掉一部分了。
h>lim1时,几何体左半部分可以减掉一个圆柱,对剩下部分积分,剩下部分左边截面的高度2*R;否则高度为2*R/cos(a);
h>lim2时,几何体右半部分截面的高度需要计算,为(h-lim2)/cos(a);否则为0.
注意:这里所说的结合体截面的高度是相对与下面的母线而言,并不是对地高度。
然后对上面给出的高度范围结合夹角a进行积分,需要推导截面的面积。最后答案需要加上截掉的那部分完整的圆柱体体积(如果是那种情况的话)。
代码:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-12
#define lowbit(x) ((x)&(-x))
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pb push_back
#define pf(x) ((x)*(x)) #define pi acos(-1.0) #define in freopen("solve_in.txt", "r", stdin);
#define out freopen("solve_out.txt", "w", stdout); #define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std; int dblcmp(double x) {
if(fabs(x) < esp) return ;
return x > ? : -;
}
const int N = ;
double R, H, a, h;
double f1(double x) {
double cth = (R-x)/R;
return acos(cth)*pf(R)-(R-x)*sqrt(pf(R)-pf(R-x));
}
double f2(double x) {
double cth = (x-R)/R;
return (pi-acos(cth))*pf(R)+(x-R)*sqrt(pf(R)-pf(x-R));
}
double s1(double l, double r) {
double x = , y = (l-r)/tan(a);
double h0 = (y-x)/N; double res = 0.0;
res = f1(l)+f1(r);
for(int i = ; i <= N; i++) {
if(i < N)
res += *f1(l-(x+i*h0)*tan(a));
res += *f1(l-(x+(*i-)*h0/)*tan(a));
}
return res*h0/; }
double s2(double l, double r) {
double x = , y = (l-r)/tan(a);
double h0 = (y-x)/N; double res = 0.0;
res = f2(l)+f2(r);
for(int i = ; i <= N; i++) {
if(i < N)
res += *f2(l-(x+i*h0)*tan(a));
res += *f2(l-(x+(*i-)*h0/)*tan(a));
}
return res*h0/;
} double getAns(double h0, double h1) {
if(h1 > R) {
return s2(h0, h1);
} else if(h0 < R) {
return s1(h0, h1);
} else {
return s2(h0, R)+s1(R, h1);
}
}
int main() { while(scanf("%lf%lf%lf%lf", &R, &H, &h, &a) == ) {
double res = 0.0;
if(fabs(a) > esp && fabs(a-90.0) > esp) {
a = a*pi/180.0;
double lim2 = sin(a)*H;
double lim1 = *R*cos(a); double h1, h2;
if(h > lim1) {
h1 = *R;
res += pi*pf(R)*(h/sin(a)-*R/tan(a));
} else {
h1 = h/cos(a);
}
if(h > lim2) {
h2 = (h-lim2)/cos(a);
} else {
h2 = 0.0;
}
res += getAns(h1, h2); } else {
if(fabs(a) < esp) {
double Sr;
if(h > R){
Sr = f2(h);
}else{
Sr = f1(h);
}
res = Sr*H;
} else {
res = pi*pf(R)*h;
}
}
printf("%.12f\n", res);
}
return ;
}
分析:第n个是将第n/2个倒插进去然后加上眼睛等部分。
代码:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-8
#define lowbit(x) ((x)&(-x))
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pb push_back
#define in freopen("solve_in.txt", "r", stdin);
#define out freopen("solve_out.txt", "w", stdout); #define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
#define Fill(x, b1, b2, l, r) {\
for(int i = ; i < l; i++)\
maze[x][i+b1][b2] = maze[x][i+b1][b2+r-] = '*';\
for(int i = ; i < r; i++)\
maze[x][b1][i+b2] = maze[x][b1+l-][i+b2] = '*';\
}\ using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef map<string, int> MPS; using namespace std;
const int maxn = ;
char s[maxn][maxn] = {
{"********"}, {"*** ***"}, {"*** ***"}, {"*** ***"}, {"* **** *"}, {"* * * *"},
{"* * * *"}, {"********"}
}; char maze[][maxn][maxn]; int popcount(int x){
int ans = ;
while(){
if(x&) break;
ans++;
x >>= ;
}
return ans;
}
void dfs(int n){
if(n <= ) return;
int x = popcount(n);
// cout << x << endl;
for(int i = ; i < n; i++) for(int j = ; j < n; j++)
maze[x][i][j] = ' ';
Fill(x, , , n, n)
int st1 = n/, st2 = st1+n/;
Fill(x, n/, st1, n/+, n/)
Fill(x, n/, st2, n/+, n/)
dfs(n>>);
int b1 = n/, b2 = n/;
int nn = n>>;
for(int i = ; i < (n>>); i++)
for(int j = ; j < (n>>); j++){
maze[x][b1+i][b2+j] = maze[x-][nn--i][nn--j];
}
}
int main() { int n;
for(int i = ; i < ; i++)
strcpy(maze[][i], s[i]);
dfs(); while(scanf("%d", &n), n >= ) {
// cout << n <<endl;
int x = popcount(n);
// cout << x << endl;
for(int i = ; i < n; i++)
puts(maze[x][i]);
puts("");
}
return ;
}
分析:对每个点和其对称点访问一遍,将数目最多的那种保留,其他全部替换成这种。
代码:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define esp 1e-8
#define lowbit(x) ((x)&(-x))
#define lson l, m, rt<<1
#define rson m+1, r, rt<<1|1
#define sz(x) ((int)((x).size()))
#define pb push_back
#define in freopen("solve_in.txt", "r", stdin);
#define out freopen("solve_out.txt", "w", stdout); #define bug(x) printf("Line : %u >>>>>>\n", (x));
#define inf 0x0f0f0f0f
using namespace std;
const int maxn = ;
char maze[maxn][maxn];
int vis[maxn][maxn];
vector<char> tmp;
int n; void dfs(int x, int y){
if(vis[x][y]) return;
vis[x][y] = ;
tmp.pb(maze[x][y]);
dfs(y, x);
dfs(n--y, n--x);
dfs(n--x, y);
dfs(x, n--y);
}
int main(){ int T;
for(int t = scanf("%d", &T); t <= T; t++){
scanf("%d", &n);
int ans = ;
for(int i = ; i < n; i++)
scanf("%s", maze[i]);
// for(int i = 0; i < n; i++)
// cout << maze[i];
memset(vis, , sizeof vis);
for(int i = ; i < n; i++)for(int j = ; j < n; j++){
if(vis[i][j]) continue;
tmp.clear();
dfs(i, j);
sort(tmp.begin(), tmp.end());
int jj;
int mx = ;
for(int ii = ; ii < sz(tmp); ii = jj){
int ok = ;
for(jj = ii; jj < sz(tmp) && tmp[jj] == tmp[ii]; jj++)
ok++;
mx = max(ok, mx);
}
ans += sz(tmp)-mx;
}
cout << ans << endl;
}
return ;
}
ZOJ Monthly, November 2014的更多相关文章
- 137 - ZOJ Monthly, November 2014 - J Poker Face
Poker Face Time Limit: 2 Seconds Memory Limit: 65536 KB As is known to all, coders are lack of ...
- 浙大月赛ZOJ Monthly, August 2014
Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...
- 135 - ZOJ Monthly, August 2014
135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][ ...
- ZOJ Monthly, November 2012
A.ZOJ 3666 Alice and Bob 组合博弈,SG函数应用 #include<vector> #include<cstdio> #include<cstri ...
- ZOJ Monthly, August 2014
A Abs Problem http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5330 找规律题,构造出解.copyright@ts ...
- ZOJ Monthly, June 2014 月赛BCDEFGH题题解
比赛链接:点击打开链接 上来先搞了f.c,,然后发现状态不正确,一下午都是脑洞大开,, 无脑wa,无脑ce...一样的错犯2次.. 硬着头皮搞了几发,最后20分钟码了一下G,不知道为什么把1直接当成不 ...
- 记次浙大月赛 134 - ZOJ Monthly, June 2014
链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类 ...
- ZOJ Monthly, June 2014 解题报告
A.Another Recurrence Sequence problemId=5287">B.Gears 题目大意:有n个齿轮,一開始各自为一组.之后进行m次操作,包含下面4种类型: ...
- ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)
题目链接 ZOJ Monthly, March 2018 Problem G 题意 给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...
随机推荐
- [Bootstrap]全局样式(一)
页面必须设置为html5文档类型 <!DOCTYPE html> <html lang="zh-CN"> ... </html> 适应移动设备 ...
- dorado spring知识补充
一定要加context配置,无法扫描到注入@Componet的类 在app-context.xml添加一句代码 <context:component-scan base-package=&quo ...
- c#基础学习汇总----------继承
封装,继承,多态.这是面向对象的思想,也可以说是最基本的东西.说到继承,直接的说他就是面向对象中类与类之间的一种关系.通过继承,使得子类具有父类公有的受保护访问权限的属性和方法,同时子类可以通过加入新 ...
- ZigBee NV层使用
原文转载于http://www.cnblogs.com/yqh2007/archive/2011/05/31/2065284.html 系统NV区:初始化nv数据项 osal_nv_item_in ...
- 一种简单的权限管理ER图设计
权限管理支持动态地管理用户的角色和权限.权限代表用户可以在什么对象上进行什么操作:角色是一组权限的集合. PS:当增加或删除某个用户的角色时,系统自动将该角色对应的权限(角色 -权限关联表)增加或删除 ...
- Entity Framework Code First 迁移数据库
新版EF,系统实现过程中如果对Model进行更改,队形修改数据库并不能正常运行项目,需要借助Code First 手动迁移数据库 首先启用迁移,允许迁移Context Tools->Librar ...
- RequireJS入门与进阶
RequireJS由James Burke创建,他也是AMD规范的创始人. RequireJS会让你以不同于往常的方式去写JavaScript.你将不再使用script标签在HTML中引入JS文件,以 ...
- Windows平台下为Python添加MySQL支持
到Python官网下载MySQL-python-1.2.5.win32-py2.7.exe 安装MySQL-python-1.2.5.win32-py2.7 附 64位MySQL-python下载地址 ...
- hibernate的n+1问题
下面选自<精通Hibernate:Java对象持久化技术详解>作者:孙卫琴 在Session的缓存中存放的是相互关联的对象图.默认情况下,当Hibernate从数据库中加载Customer ...
- ubuntu中替代visio的软件 dia
ubuntu 中 软件 dia 可以替代 ms-visio软件. 安装过程可以在线安装: sudo apt-get install dia