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 ...
随机推荐
- C#之委托如此简单
近期和几位做嵌入式开发的朋友闲聊过程中,一位朋友抱怨到:这C#太难用了,我想在N个窗体(或者是N个用户组件之间)传递值都搞不定,非得要定义一个全局变量来存储,然后用定时器来刷新值,太Low了.我急切的 ...
- Netty连接处理那些事
编者注:Netty是Java领域有名的开源网络库,特点是高性能和高扩展性,因此很多流行的框架都是基于它来构建的,比如我们熟知的Dubbo.Rocketmq.Hadoop等,针对高性能RPC,一般都是基 ...
- 用js和css实现选项卡效果+jq(2019-10-09)
1效果图: 2代码: html: <!DOCTYPE html> <html> <head> <meta charset="UTF-8"& ...
- git命令--subtree
目录 git命令--subtree subtree 主要命令 git subtree add --prefix=<prefix> <commit> git subtree ...
- 《JS高程》-教你如何写出可维护的代码
1.前言 在平时工作开发中,大部分开发人员都花费大量的时间在维护其他人员的代码.很难从头开始开发新代码,很多情况下都是以他人成果为基础的,或者新增修改需求,自己写的代码也会被其他开发人员调用,所以 ...
- postman-接口间数据传递
接口间数据传递 在我们做接口测试过程中会经常碰到使用上一个接口返回数据的情况,jmeter中可通过正则表达式提取,postman中如何提取呢?我们来看实例,这里使用的同一个接口来演示. 我们提取出 ...
- C#中的取整函数
先放百度的 Math.Ceiling();向上取整 Math.Ceiling()向上取整: d = 4.56789 string res = Math.Ceiling(Convert.ToDecima ...
- Zabbix日志监控插件
#!/usr/bin/env python # coding:utf-8 import re import os import sys import logging logging.basicConf ...
- python脚本 环境准备
现在的公司用 Python 做 Web 开发,入职到现在为止(三个月),算是入门了 Python Web 开发 但是 Python 本身是脚本语言,我还从来没有体会到脚本语言能给日常工作带来的便利 就 ...
- 《计算机网络 自顶向下方法》 第3章 运输层 Part2
待补充完善 TCP 相关基本点 1.面向连接 两个不同主机上的进程在通过 TCP 进行通信之前,必须先通过三次握手来建立 TCP 连接 2.全双工服务 即,如果一台主机上的进程 A 与另一台主机上的进 ...