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 ...
随机推荐
- 学习笔记03http协议
1.浏览器就是一个sokect客户端,使用http协议与服务器进行交流.http请求:请求头:(请求方法)sp(url)sp http/1.x <cr><lf>(通用头类型名) ...
- SROP的一个实例
以前一直只是大概看过这种技术,没实践过,今天刚好遇到一道题,实践了一波,确实很方便 unmoxiao@cat ~/s/pd_ubuntu> r2 -A smallest 00:54:15 War ...
- mysql-清除binlog日志命令
记录一个清除MySQL里binlog日志的命令,可用在定时任务脚本里. 只保留1天前的日志: PURGE MASTER LOGS BEFORE DATE_SUB(CURRENT_DATE, INTER ...
- wordpress插件:multiple post thumbnails(可为文章添加多个特色图片)
我们经常会给wordpress的文章加上特色图片来实现日志缩略图的需求,但是很多时候一张图片并不能够完美而又全面的表达我们wordpress文章的内容,这时候您可能就会需要这样一个能让wordpres ...
- GC四大算法
引言: 前面的文章提到,Heap包括了PSYoungGen.ParOldGen.Metaspace.JVM 在进行GC时,并非每次都对上面三个内存区域一起回收的,大部分时候回收的都是新生代.由于新生代 ...
- web应用安全框架选型:Spring Security与Apache Shiro
一. SpringSecurity 框架简介 官网:https://projects.spring.io/spring-security/ 源代码: https://github.com/spring ...
- python关于urllib库与requests
对于这两个库来说个人推荐使用requests库 下面用实例来说明 urllib库: requests库: 实现同样功能: 实现同样的功能下urllib比request步骤更复杂,这个对于我们编程来说是 ...
- MySQL系列:MySQL的基本使用
数据库的基本操作 在MySQL数据库中,对于一个MySQL示例,是可以包含多个数据库的. 在连接MySQL后,我们可以通过 show databases; 来进行查看有那么数据库.这里已经存在一些库了 ...
- 微信 AES 解密报错 Illegal key size 三种解决办法
微信 AES 解密报错 Illegal key size Java 环境 java version "1.8.0_151" Java(TM) SE Runtime Environm ...
- Feign 调用丢失Header的解决方案
问题 在 Spring Cloud 中 微服务之间的调用会用到Feign,但是在默认情况下,Feign 调用远程服务存在Header请求头丢失问题. 解决方案 首先需要写一个 Feign请求拦截器,通 ...