Education Round16

A题:
题意:给定国际象棋king的坐标,求能向几个方向移动
分析:处理一下边界情况,其他的都是8

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <string>
 5 #include <vector>
 6 #include <algorithm>
 7 #include <set>
 8 #include <map>
 9 #include <bitset>
10 #include <cmath>
11 #include <queue>
12 #include <stack>
13 using namespace std;
14 string s;
15 int main()
16 {
17     while(cin>>s)
18     {
19         if((s[0]!=‘a‘&&s[0]!=‘h‘)&&(s[1]!=‘1‘&&s[1]!=‘8‘))
20             cout<<"8"<<endl;
21         else
22         {
23             if(s[0]==‘a‘||s[0]==‘h‘)
24             {
25                 if(s[1]==‘1‘||s[1]==‘8‘)
26                     cout<<"3"<<endl;
27                 else
28                     cout<<"5"<<endl;
29             }
30             else
31                 cout<<"5"<<endl;
32         }
33     }
34     return 0;
35 }

B题:
题意:给定一条直线上的一些点,求到这些点距离最近的点的坐标
分析:有推倒可以得到,我们可以把坐标先排序,如果有偶数个则取中间一个,如果有奇数个取中间一个的下一个

 1 #include <iostream>
 2 #include <cstdio>
 3 #include <cstring>
 4 #include <string>
 5 #include <vector>
 6 #include <algorithm>
 7 #include <set>
 8 #include <map>
 9 #include <bitset>
10 #include <cmath>
11 #include <queue>
12 #include <stack>
13 using namespace std;
14 const int maxn=300010;
15 const int INF=1<<30;
16 int a[maxn];
17 int n;
18 int main()
19 {
20     while(cin>>n)
21     {
22         for(int i=1;i<=n;i++)
23            scanf("%d",&a[i]);
24         sort(a+1,a+1+n);
25         int k=n/2;
26         if(n%2==0)
27         cout<<a[n/2]<<endl;
28         else
29         cout<<a[n/2+1]<<endl;
30     }
31     return 0;
32 }

时间: 2024-10-04 23:26:10

Education Round16的相关文章

《The Story of My Life》Introductiom - Historical and Literary Context - Education of the Deaf and Blind

At the time the Story of My Life was published, the idea of a disabled person as an active member of society was radical. Through there were institutes for deaf students and blind students in America, they emphasized vocational education, training th

【转载】免费台北.edu教育邮箱及Office 365 Education申请

免费的邮箱非常多,但是免费的.edu教育邮箱却很少有.记得上次不少人寻找.edu教育邮箱还是因为国外一家VPS商家推出的专门针对学生的优惠包,使用.edu教育邮箱就可以获得50美元的优惠,真的很划算. 拥有.edu教育邮箱还有其它好处,例如获得Office365免费使用权限,可以免费扩容Onedrive至1024GB,GitHub提供的GitHub Student Developer Pack,JetBrains Toolbox 专业开发工具学生免费授权计划等等. 本篇文章就来为大家分享一下申请

Parents in education children don&#39;t begrudge to encourage son too

Parents should not fail to encourage children in education, for he's too strict. Zhu Youyun to pay me 90000 yuan of cash. China Shandong network " because real-name reporting/real-name whistleblowing corruption failed to tell the specific characteris

1 School & Education

1 School & Education go abroad study abroad attend college attend university begin formal education get a good education go to a private school offer an education opportunity take an orientation course major in a field of study develop expertise in s

Reuse Is About People and Education, Not Just Architecture

? Reuse Is About People and Education, Not Just Architecture Jeremy Meyer you MigHT AdopT THE AppRoACH that a framework that is well designed, or an architecture that is carefully considered and cleverly implemented, will lend itself to reuse within

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 spend the next few months growing our library of content and improving our site before the start of the next school year. With everything on our site be

【CodeForces】915 E. Physical Education Lessons 线段树

[题目]E. Physical Education Lessons [题意]10^9范围的区间覆盖,至多3*10^5次区间询问. [算法]线段树 [题解]每次询问至多增加两段区间,提前括号分段后线段树. #include<cstdio> #include<cctype> #include<set> #include<algorithm> using namespace std; int read(){ char c;int s=0,t=1; while(!i

[Educational Codeforces Round 36]E. Physical Education Lessons

[Educational Codeforces Round 36]E. Physical Education Lessons <题意概括> 给定一个长度为$N\left(1\leqslant N\leqslant10^{9}\right)$的区间 $Q\left(1\leqslant Q\leqslant3\cdot10^{5}\right)$次将区间$\left[L,R\right]$Set为0或1,每次Set后输出区间总和 <做法> $10_{9}$的范围显然不可能是朴素线段树

Codeforces 915 E Physical Education Lessons

题目描述 This year Alex has finished school, and now he is a first-year student of Berland State University. For him it was a total surprise that even though he studies programming, he still has to attend physical education lessons. The end of the term i