Education Round16
A题:
题意:给定国际象棋king的坐标,求能向几个方向移动
分析:处理一下边界情况,其他的都是8
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
string s;
int main()
{
while(cin>>s)
{
if((s[]!='a'&&s[]!='h')&&(s[]!=''&&s[]!=''))
cout<<""<<endl;
else
{
if(s[]=='a'||s[]=='h')
{
if(s[]==''||s[]=='')
cout<<""<<endl;
else
cout<<""<<endl;
}
else
cout<<""<<endl;
}
}
return ;
}
B题:
题意:给定一条直线上的一些点,求到这些点距离最近的点的坐标
分析:有推倒可以得到,我们可以把坐标先排序,如果有偶数个则取中间一个,如果有奇数个取中间一个的下一个
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
using namespace std;
const int maxn=;
const int INF=<<;
int a[maxn];
int n;
int main()
{
while(cin>>n)
{
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
sort(a+,a++n);
int k=n/;
if(n%==)
cout<<a[n/]<<endl;
else
cout<<a[n/+]<<endl;
}
return ;
}
Education Round16的更多相关文章
- Codeforces 915E Physical Education Lessons
原题传送门 我承认,比赛的时候在C题上卡了好久(最后也不会),15min水掉D后(最后还FST了..),看到E时已经只剩15min了.尽管一眼看出是离散化+线段树的裸题,但是没有时间写,实在尴尬. 赛 ...
- CF915E Physical Education Lessons 动态开点线段树
题目链接 CF915E Physical Education Lessons 题解 动态开点线段树 代码 /* 动态开点线段树 */ #include<cstdio> #include&l ...
- 【题解】Luogu CF915E Physical Education Lessons
原题传送门:CF915E Physical Education Lessons 前置芝士:珂朵莉树 窝博客里对珂朵莉树的介绍 没什么好说的自己看看吧 这道题很简单啊 每个操作就是区间赋值,顺带把总和修 ...
- 2.Early Education of Children 儿童的早期教育
2.Early Education of Children 儿童的早期教育 (1) In bringing up children,every parent watches eagerly the c ...
- 1.The Necessity of a Broad Education 全面教育的必要性
1.The Necessity of a Broad Education 全面教育的必要性 (1) According to a survey,which was based on the respo ...
- L219 China's office workers consider further education, training essential
More than 90 percent of China's office workers consider on-the-job training and continuing education ...
- CF915E Physical Education Lessons
题意: Alex高中毕业了,他现在是大学新生.虽然他学习编程,但他还是要上体育课,这对他来说完全是一个意外.快要期末了,但是不幸的Alex的体育学分还是零蛋! Alex可不希望被开除,他想知道到期末还 ...
- Give $20/month and provide 480 hours of free education
Hi , Hope all is well. Summer is right around the corner, and the Khan Academy team is excited to sp ...
- 【CodeForces】915 E. Physical Education Lessons 线段树
[题目]E. Physical Education Lessons [题意]10^9范围的区间覆盖,至多3*10^5次区间询问. [算法]线段树 [题解]每次询问至多增加两段区间,提前括号分段后线段树 ...
随机推荐
- C#获取周的第一天、最后一天、月第一天和最后一天
[csharp] view plaincopyprint? public class DateTimeTool { /// <summary> /// 获取指定日期所在周的第一天,星期天为 ...
- java memcache应用
import java.io.Serializable; import java.text.DateFormat; import java.util.Date; import java.util.Ma ...
- WinForm 子窗体在父窗体范围内移动,不能出父窗体 摘自于网络
详细解释:1, 主窗体Form1属性IsMdiContainer设为True,并添加ToolStrip控件, Toolstrip中添加一个按钮toolStripButton1. 2,添 ...
- ListBox之类控件的Item项显示对象的两个属性
wpf项目中,ListBox绑定对象集合,ListBoxItem要显示对象的两个属性,例如:显示员工的工号和姓名. 之前我的做法是在Employee员工类中添加一个"NumAndName&q ...
- python2.x 使用protobuf
1.在windows下配置protobuf 1.1 下载对应的包,包含两个:protoc.exe和源码文件(protoc也可以自己生成) 下载地址1 --- google code最近在迁移,也许以后 ...
- Flexigrid的API
基本设定 width table的长度(default:auto) height table的宽度(default:200) striped 表格的线的表示(default:true) nov ...
- mplayer最全的命令
前段时间做过qt内嵌mplayer的一个小程序,感觉mplayer还行不过不支持打开图片感觉有点无力.话不多说上代码: QString path="d:/1.mkv"; QWidg ...
- Discuz登录慢、退出也慢的原因?
Discuz登录慢.退出也慢的原因? 2009-02-21 12:50:11 分类: 转载自:http://www.aiseminar.cn/bbs/thread-201-1-1.html 由于服务 ...
- U3D游戏开发基础
向量: 1. 向量的长度,即向量的模.计算公式为向量各个分量的平方和,然后开平方. 在D3DX库中,方法为:FLOAT D3DXVec3Length(CONST D3DXVECTOR3 * pV) ...
- Android系统权限及签名
Android系统权限及签名 2015-03-23 19:13:33CSDN-chen52671-点击数:50 Android权限及签名 引子 现象:系统中的一个定制Service,服务是 ...