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$表示存在一种 ...
随机推荐
- 关于百度编辑器UEditor(1.4.3)在C#.NET中的应用实例
首先去百度UEditor官网下载 1.4.3 .net版本 http://ueditor.baidu.com/build/build_down.php?n=ueditor&v=1_4_3-ut ...
- 【转载】绝对干货!Linux小白最佳实践:《超容易的Linux系统管理入门书》(连载九)如何通过源代码安装软件
除了使用Linux的包管理机制进行软件的安装.更新和卸载,从源代码进行软件的安装也是非常常见的,开源软件提供了源代码包,开发者可以方便的通过源代码进行安装.从源码安装软件一般经过软件配置.编译软件.执 ...
- UVALive 2889(回文数字)
题意:给定i,输出第i个回文数字. 分析:1,2,3,4,……,9------------------------------------------------------------------- ...
- 提升程序的特权(AdjustTokenPrivileges)
首先列出需要的函数 1.OpenProcessToken 2.AdjustTokenPrivileges 3. LookupPrivilegeValue ----------------------- ...
- MFC中获取指针的方法
1.获取应用程序指针 CMyApp* pApp=(CMyApp*)AfxGetApp(); 2.获取主框架指针 CWinApp 中的公有成员变量 m_pMainWnd 就是主框架的指针 CMainFr ...
- rabbitmq+haproxy+keepalived实现高可用集群搭建
项目需要搭建rabbitmq的高可用集群,最近在学习搭建过程,在这里记录下可以跟大家一起互相交流(这里只是记录了学习之后自己的搭建过程,许多原理的东西没有细说). 搭建环境 CentOS7 64位 R ...
- Axure RP 各个版本中文版 汉化包 破解版 下载地址及注册码
导读:Axure RP Pro是一个产品经理必备的交互原型设计工具,能够高效率制作产品原型,快速绘制线框图.流程图.网站架构图.示意图.HTML模版等.Axure RP已被一些大公司采用.Axure ...
- JS焦点图,JS 多个页面放多个焦点图
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- ActiveMq+zookeeper+levelDB集群整合配置
ActiveMq+zookeeper+levelDB集群整合配置 环境:linux系统,jdk1.7 三台linux系统电脑.我这里使用一台window,分别远程3台linux电脑.三台电脑的ip分 ...
- angularJs--<ui-select>
显示: ng-model里面的变量 如果为1,会去 ui-select-choices 里找这个idea数组,然后把数组对应name字段的值,交给 ui-select-match里面显示,$selec ...