Good Bye 2017 A B C
Good Bye 2017
A New Year and Counting Cards
题目链接:
http://codeforces.com/contest/908/problem/A
思路:
如果卡片上面是数字,如果是奇数,就需要检查一下。如果是字母,如果是原音字母,需要检查一下。
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1504;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
string s,t;
t="aeiou";
cin>>s;
int ans=0;
int lens=s.length();
int lent=t.length();
for(int i=0;i<lens;++i) {
if(s[i]>='0'&&s[i]<='9') {
int num=s[i]-'0';
if(num%2) ++ans;
} else {
for(int j=0;j<lent;++j) {
if(s[i]==t[j]) {
++ans;
break;
}
}
}
}
cout<<ans<<endl;
return 0;
}
B New Year and Buggy Bot
题目链接:
http://codeforces.com/contest/908/problem/B
思路:
设置方向数组,全排列。暴力DFS检查每一种的可能性。要注意DFS判断最后一步的下标,少了最后一步,结果WA8,好可惜...
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 55;
char mp[maxn][maxn];
char op[105];
int n,m,sx,sy,ex,ey;
int a[4]={0,1,2,3};
int ans=0;
int len;
bool dfs(int x, int y, int index) {
if(index>=len) {
if(x==ex&&y==ey) return true;
return false;
}
if(x==ex&&y==ey) return true;
int xx,yy;
for(int i=0;i<4;++i) {
if(op[index]-'0'==a[i]) {
if(i==0) {
xx=x;
yy=y-1;
} else if(i==1) {
xx=x-1;
yy=y;
} else if(i==2) {
xx=x;
yy=y+1;
} else if(i==3) {
xx=x+1;
yy=y;
}
}
}
if(xx<0||xx>=n||yy<0||yy>=m) return false;
if(mp[xx][yy]=='#') return false;
return dfs(xx,yy,index+1);
}
int main() {
scanf("%d %d",&n,&m);
for(int i=0;i<n;++i) scanf("%s",mp[i]);
scanf("%s",op);
len=strlen(op);
for(int i=0;i<n;++i) {
for(int j=0;j<m;++j) {
if(mp[i][j]=='S') {
sx=i;
sy=j;
} else if(mp[i][j]=='E') {
ex=i;
ey=j;
}
}
}
do {
if(dfs(sx,sy,0)) ++ans;
} while(next_permutation(a,a+4));
printf("%d\n",ans);
return 0;
}
C New Year and Curling
题目链接:
http://codeforces.com/contest/908/problem/C
思路:
这道题目,按照先后顺序依次访问每一个掉落下来的圆。计算和之前的圆是否存在相交或者是相切的关系,如果存在,计算出纵坐标。然后在纵坐标中渠道最大值即可。因为碰到第一个圆就停止了,不可能再与其他的圆相切。
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1005;
int x[maxn];
double y[maxn];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n,r;
cin>>n>>r;
for(int i=1;i<=n;++i) {
cin>>x[i];
y[i]=r*1.0;
}
for(int i=2;i<=n;++i) {
for(int j=i-1;j>=1;--j) {
int ll=1005,rr=1;
ll=min(min(ll,x[j]-r),x[i]-r);
rr=max(max(rr,x[j]+r),x[i]+r);
if(rr-ll>4*r) continue;
double temp=sqrt(4*r*r*1.0-(x[i]*1.0-x[j]*1.0)*(x[i]*1.0-x[j]*1.0))+y[j];
y[i]=max(temp,y[i]);
}
}
for(int i=1;i<=n;++i) {
if(i==1) cout<<setiosflags(ios::fixed)<<setprecision(8) << y[i];
else cout<<" "<<setiosflags(ios::fixed)<<setprecision(8) << y[i];
}
cout<<endl;
return 0;
}
Good Bye 2017 A B C的更多相关文章
- Hello 2018, Bye 2017
2017年过去了,过去一年经历了太多,改变了好多好多,可以说人生进入了另一个阶段,有可能是成熟吧. 回顾2017 去年换了新工作,离开了将近工作了8年的公司,不带走一丝云彩,为其任劳任怨,最后没有任何 ...
- Good Bye 2017(送命场)
9815人数场,9500+围观神仙打架...断断续续打Codeforces也快有一年啦,第一次打Good Bye场,满怀前排膜tourist的心愿参加了这场送命场,虽然没看到tourist.不过还是得 ...
- Good Bye 2017 E. New Year and Entity Enumeration
先按照绿点进行分块 第一个绿点和最后一个绿点之后很好处理不说了 两个绿点之间的讨论: 有两种方案 1:红(蓝)点和绿点顺序连接,距离为相邻绿点距离(也就是双倍绿点距离) 2:红(蓝)点和绿点的点阵中寻 ...
- Good Bye 2017 D. New Year and Arbitrary Arrangement
看了别人的题解 首先这题是一个dp dp[i][j] i是当前有多少个a j是当前有多少个ab子序列 dp[i][j] = dp[i+1][j]*Pa + dp[i][i+j]*Pb; i,j 时加一 ...
- Good Bye 2017 G. New Year and Original Order
G. New Year and Original Order time limit per test 2 seconds memory limit per test 256 megabytes inp ...
- Good Bye 2017 C. New Year and Curling
Carol is currently curling. She has n disks each with radius r on the 2D plane. Initially she has al ...
- Good Bye 2017 部分题解
D. New Year and Arbitrary Arrangement 分析 \(dp[i][j]\) 表示已有 \(i\) 个 \(a\) 和 \(j\) 个 \(ab\) 的情况下继续构造能得 ...
- Good Bye 2017
太菜了啊,一不小心就goodbye rating了 A. New Year and Counting Cards time limit per test 1 second memory limit p ...
- 【EOJ Monthly 2018.2 (Good bye 2017)】
23333333333333333 由于情人节要回家,所以就先只放代码了. 此题是与我胖虎过不去. [E. 出老千的 xjj] #include<cstdio> #include<c ...
随机推荐
- Centos6 Tengine开启http2传输协议
1.前言 最近在优化网站的访问速度,为网站开启http2协议,这个协议有什么优点呢?如下: http2是下一代的传输协议,以后都会普遍用它,是一个趋势. http2有多路复用特性,意思是访问一个域名下 ...
- 【Java必修课】String.intern()原来还能这么用(原理与应用)
1 简介 String.intern()是JDK一早就提供的native方法,不由Java实现,而是底层JVM实现,这让我们对它的窥探提高了难度.特别是在Oracle收购了Sun公司后,源代码不开源了 ...
- 水管局长数据加强版:lct,时光倒流,最小生成树,边化点
Description: SC省MY市有着庞大的地下水管网络,嘟嘟是MY市的水管局长(就是管水管的啦),嘟嘟作为水管局长的工作就是:每天供水公司可能要将一定量的水从x处送往y处,嘟嘟需要为供水公司找到 ...
- 「刷题」可怜与STS
又是一道假期望,我们发现一共有$ C_{2n}^m $种情况. 而$ \frac{(2n)!}{m!(2n-m)!}=C_{2n}^m $ 其实结果就是各个情况总伤害. 1.10分算法,爆搜10分. ...
- Js对象继承小结
1.继承 对象的定义好用一些的一般是把实例对象的属性定义在类里面,通过this指针指向具体实例属性.定义对象的public方法时将其绑定到prototype中.子类在继承父类时可以通过对象冒充来继承父 ...
- Linux Shell | 解析xml节点
01 xml文件 # user.xml <user> <name>Toy</name> <sex>man</sex> <room/&g ...
- web常用自动化库——selenium总结
概述 selenium是一个模拟控制浏览器操作的自动化库,它可以做到元素定位,鼠标事件,浏览器事件,js脚本执行等操作 与request不同的是,request是单独请求一个http,而seleniu ...
- Abp vNext 自定义 Ef Core 仓储引发异常
问题 在使用自定义 Ef Core 仓储和 ABP vNext 注入的默认仓储时,通过两个 Repository 进行 Join 操作,提示 Cannot use multiple DbContext ...
- 4、Vim编辑器与正则表达式-面试题
题目 自己写答案
- 《计算机网络 自顶向下方法》 第3章 运输层 Part2
待补充完善 TCP 相关基本点 1.面向连接 两个不同主机上的进程在通过 TCP 进行通信之前,必须先通过三次握手来建立 TCP 连接 2.全双工服务 即,如果一台主机上的进程 A 与另一台主机上的进 ...