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$表示存在一种 ...
随机推荐
- javascript笔记——js面试问题
1:javascript中的变量提升(先使用再声明,js中的函数也存在函数提升) 2:js中的事件捕获和事件冒泡(是两个相反的过程) 3:js中的动画队列(比如animate动画没有在点击的时候阻止正 ...
- linux 定时任务 crontab
为当前用户创建cron服务 1. 键入 crontab -e 编辑crontab服务文件 例如 文件内容如下: */2 * * * * /bin/sh /home/admin/jiaoben/bu ...
- Mac OS X开发者准备工作
迁移到Mac平台做开发后,需要有一系列的准备工作来使我们的工作更顺畅. 1. 安装Homebrew包管理器 苹果系统自带了一个包管理器,但是并不是很好用.现在,现在比较流行的是Homebrew,非常好 ...
- Android Animation ---TranslateAnimation
if(stopBtn.getVisibility()==View.VISIBLE){ Animation animation_stop = new TranslateAnimation( Animat ...
- Jquery 禁用 a 标签 onclick 事件30秒后可用
<a href="javascript:;" id="sendToTel" >发送短信</a> <script type=&quo ...
- C# 实现HTML5服务器推送事件
为什么需要服务器推送事件: 因为如果需要保持前台数据的实时更新例如,IM聊天,股票信息, 1.可以在客户端不断地调用服务端的方法来获得新数据,但是这样会很消耗服务器资源,导致系统变慢! 2 html5 ...
- 使用visual studio测试功能进行暴力破解
web项目上线前需要做访问压力测试,奈何对这方面不懂,所以自己网上搜索了下相关工具没有找到合适的,就自己研究了下visual studio 2013中的测试项目,发现还挺好使的,结合数据库还能用做暴力 ...
- Jquery实现手机上下滑屏滑动的特效代码
要引入两个jquery插件 可以去网上下载 <script src="jquery-1.11.1.min.js"></script><script s ...
- Asp.net Response.Redirect with post data
string url = String.Format("{0}://{1}/{2}", Request.Url.Scheme, Request.Url.Authority, &qu ...
- dbt
Procedure Relocate(s : state; b : base_index) { Move base for state s to a new place beginning at b ...