Codeforces710
【未完待续】
A
The only king stands on the standard chess board. You are given his position in format "cd", where c is the column from 'a' to 'h' and dis the row from '1' to '8'. Find the number of moves permitted for the king.
King moves from the position e4
The only line contains the king's position in the format "cd", where 'c' is the column from 'a' to 'h' and 'd' is the row from '1' to '8'.
Print the only integer x — the number of moves permitted for the king.
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#define il inline
#define re register
using namespace std;
string a;
int main(){
cin>>a;
if(a[]=='a'||a[]=='h'){
if(a[]==''||a[]=='')
cout<<"";
else cout<<"";
}
else{
if(a[]==''||a[]=='')
cout<<"";
else cout<<"";
}
return ;
}
B
You are given n points on a line with their coordinates xi. Find the point x so the sum of distances to the given points is minimal.
The first line contains integer n (1 ≤ n ≤ 3·10^5) — the number of points on the line.
The second line contains n integers xi ( - 10^9 ≤ xi ≤ 10^9) — the coordinates of the given n points.
Print the only integer x — the position of the optimal point on the line. If there are several optimal points print the position of the leftmost one. It is guaranteed that the answer is always the integer.
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#define il inline
#define re register
using namespace std;
int n,a[];
int main(){
scanf("%d",&n);
for(int i=;i<=n;i++)
scanf("%d",&a[i]);
sort(a+,a+n+);
if(n&){
cout<<a[n/+];
}
else{
cout<<a[n/];
}
return ;
}
C
Find an n × n matrix with different numbers from 1 to n2, so the sum in each row, column and both main diagonals are odd.
The only line contains odd integer n (1 ≤ n ≤ 49).
Print n lines with n integers. All the integers should be different and from 1 to n2. The sum in each row, column and both main diagonals should be odd.
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#define il inline
#define re register
using namespace std;
int x=,y,cnt=,n,a[][];
int main(){
cin>>n;y=n/+;
while(cnt<=n*n){
a[x][y]=(cnt++);
if(x==){
if(y==n){
x=;y=n;
}
else{
x=n;y++;
}
}
else if(y==n){
x--;y=;
}
else{
if(a[x-][y+]>){
x++;
}
else{
x--;y++;
}
}
}
for(int i=;i<=n;i++){
for(int j=;j<=n;j++)
cout<<a[i][j]<<" ";
cout<<endl;
}
return ;
}
E
zscoder wants to generate an input file for some programming competition problem.
His input is a string consisting of n letters 'a'. He is too lazy to write a generator so he will manually generate the input in a text editor.
Initially, the text editor is empty. It takes him x seconds to insert or delete a letter 'a' from the text file and y seconds to copy the contents of the entire text file, and duplicate it.
zscoder wants to find the minimum amount of time needed for him to create the input file of exactly n letters 'a'. Help him to determine the amount of time needed to generate the input.
The only line contains three integers n, x and y (1 ≤ n ≤ 10^7, 1 ≤ x, y ≤ 10^9) — the number of letters 'a' in the input file and the parameters from the problem statement.
Print the only integer t — the minimum amount of time needed to generate the input file.
可以花费x的代价使得一个数加一或者减一,或者y的代价使得他乘2,问达到n需要多少的代价
这道题嘛,非常巧妙,看dp方程就ok了,主要是利用了减一之前必须乘2的性质【废话】
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#define il inline
#define re register
using namespace std;
typedef long long ll;
ll f[];
int n,x,y;
int main(){
scanf("%d%d%d",&n,&x,&y);
for(int i=;i<=n;i++){
f[i]=min(f[i-]+x,f[(i+)>>]+y+x*(i&));
}
printf("%I64d",f[n]);
return ;
}
Codeforces710的更多相关文章
随机推荐
- 向大学说拜拜——大学 > 兴趣 + 时间 + 思考 + 实践
[人物素描] 大学期间,担任过班委,加入过学生会,参加过社团,拿过奖学金......而印象最深刻的莫过于参加并组织过ACM集训,以及参加过导师的国家自然科学基金项目了.毕业时顺利拿到一波offer,并 ...
- python3.0 day02 列表、元组 、字典、字符串操作
1.列表.元组操作 列表是我们最以后最常用的数据类型之一,通过列表可以对数据实现最方便的存储.修改等操作,类似于其他语言中的数组. 定义列表 names = ['Lioa',"Tenglan ...
- javaweb(十一)——使用Cookie进行会话管理
一.会话的概念 会话可简单理解为:用户开一个浏览器,点击多个超链接,访问服务器多个web资源,然后关闭浏览器,整个过程称之为一个会话. 有状态会话:一个同学来过教室,下次再来教室,我们会知道这个同学曾 ...
- JS继承方法
1.原型链: 每个构造函数都有一个原型对象,且有一个指针指向该原型对象(prototype),原型对象都包含一个指向构造函数的指针(constructor),而实例都包含一个指向原型对象的内部指针(p ...
- Intellij IDEA破解激活
本文使用破解补丁激活Intellij IDEA 第一步:下载破解补丁(http://idea.lanyus.com/) 第二步:将下载好的补丁放置磁盘的任意位置,下面是我放置的位置 第三步:打开Int ...
- 爬虫2.3-scrapy框架-post、shell、验证码
目录 scrapy框架-post请求和shell 1. post请求 2. scrapy shell 3. 验证码识别 scrapy框架-post请求和shell 1. post请求 scrapy框架 ...
- v-for 指令
JS部分: var app = new Vue({ el: "#app", data() { return { list: [1, 2, 3, 4], objList: [ { i ...
- Laxcus大数据操作系统2.0(5)- 第二章 数据组织
第二章 数据组织 在数据的组织结构设计上,Laxcus严格遵循数据和数据描述分离的原则,这个理念与关系数据库完全一致.在此基础上,为了保证大规模数据存取和计算的需要,我们设计了大量新的数据处理技术.同 ...
- 天马行空-Ops平台建设概述
1 概述 什么是Ops平台,Ops平台的目标是什么,建设的考虑点有哪些?本章节以实际生活中医院的例子来进行各形象的阐述. 医院包含各种诊断治疗设备,病历库,医生.一个孕妇需要到医院 ...
- 记录一下自己申请并使用VPS的全过程
在学习REST API的时候,想要阅读一下谷歌爸爸的api design guide,无奈无情被墙,正好在学习云相关的技术,就想到申请一个VPS来用用. 这次我选择的是hostmybytes,原因有两 ...