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

3832 Tilt Cylinder

                              

给定如图所示有盖圆柱体,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 ;
}

3839 Poker Face

分析:第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 ;
}

3838 Infusion Altar

分析:对每个点和其对称点访问一遍,将数目最多的那种保留,其他全部替换成这种。

代码:

 #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的更多相关文章

  1. 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 ...

  2. 浙大月赛ZOJ Monthly, August 2014

    Abs Problem Time Limit: 2 Seconds Memory Limit: 65536 KB Special Judge Alice and Bob is playing a ga ...

  3. 135 - ZOJ Monthly, August 2014

    135 - ZOJ Monthly, August 2014 A:构造问题,推断序列奇偶性.非常easy发现最小值不是1就是0.最大值不是n就是n - 1,注意细节去构造就可以 E:dp.dp[i][ ...

  4. ZOJ Monthly, November 2012

    A.ZOJ 3666 Alice and Bob 组合博弈,SG函数应用 #include<vector> #include<cstdio> #include<cstri ...

  5. ZOJ Monthly, August 2014

    A Abs Problem http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5330 找规律题,构造出解.copyright@ts ...

  6. ZOJ Monthly, June 2014 月赛BCDEFGH题题解

    比赛链接:点击打开链接 上来先搞了f.c,,然后发现状态不正确,一下午都是脑洞大开,, 无脑wa,无脑ce...一样的错犯2次.. 硬着头皮搞了几发,最后20分钟码了一下G,不知道为什么把1直接当成不 ...

  7. 记次浙大月赛 134 - ZOJ Monthly, June 2014

    链接 虽做出的很少,也记录下来,留着以后来补..浙大题目质量还是很高的 B 并查集的一些操作,同类和不同类我是根据到根节点距离的奇偶判断的,删点是直接新加一个点,记得福大月赛也做过类似的,并差集的这类 ...

  8. ZOJ Monthly, June 2014 解题报告

    A.Another Recurrence Sequence problemId=5287">B.Gears 题目大意:有n个齿轮,一開始各自为一组.之后进行m次操作,包含下面4种类型: ...

  9. ZOJ 4010 Neighboring Characters(ZOJ Monthly, March 2018 Problem G,字符串匹配)

    题目链接  ZOJ Monthly, March 2018 Problem G 题意  给定一个字符串.现在求一个下标范围$[0, n - 1]$的$01$序列$f$.$f[x] = 1$表示存在一种 ...

随机推荐

  1. Cocos2d-x中停止播放背景音乐

    停止背景音乐播放代码放置到什么地方比较适合呢?例如:在HelloWorld场景中,主要代码如下: bool HelloWorld::init() { return true; } void Hello ...

  2. 使用Emmet(前身Zen Coding)加速Web前端开发

    Emmet插件以前被称作为Zen Coding,是一个文本编辑器的插件,它可以帮助您快速编写HTML和CSS代码,从而加速Web前端开发.早在2009年,Sergey Chikuyonok写过一篇文章 ...

  3. 慕课网上的Bootstrap学习(二)

    表单 首先<form role="form" class="form-horizontal"></form> ,创建一个水平显示的表单. ...

  4. 常用到的Tomcat的修改方法

    1.修改端口号 打开tomcat的service.xml文件: 找到<Connector connectionTimeout="20000" port="8080& ...

  5. SQL server 常见用法记录

        -- ============================================= -- Author:                tanghong -- Create da ...

  6. Poj OpenJudge 百练 1860 Currency Exchang

    1.Link: http://poj.org/problem?id=1860 http://bailian.openjudge.cn/practice/1860 2.Content: Currency ...

  7. linux命令之vim使用-(转)vim的保存文件和退出命令

    博客地址: http://blog.sina.com.cn/s/blog_5e357d2d0100zmth.html

  8. 6款好用的Python IDE

    “工欲善其事,必先利其器”,如果说编程是程序员的手艺,那么IDE就是程序员吃饭的家伙了.一个优秀的IDE,最重要的就是在普通文本编辑之外,提供针对特定语言的各种快捷编辑功能,让程序员尽可能快捷.舒适. ...

  9. mongodb 级联操作查询时,关联条件

    ObjectId id=new ObjectId("123"); c=c.where("relation_type.$id").is(id);

  10. CSS居中的方法整合--水平居中

    原文 CSS的居中问题,是一个老生常谈的问题,各种居中方法层出不穷.是水平居中还是垂直居中?是block还是inline? 居中对象是一个还是多个?长度宽度是否确定?等等各种因素确定. 这里就从这些方 ...