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的更多相关文章
随机推荐
- Yii2 使用 faker 生成假数据
测试过程中有时候需要生成大量的假数据,faker 是一个生成假数据的类库,可以生成姓名,电话,IP地址,密码,ISBN等等你能想到的或者你想不到的各种类型的假数据. Yii2.0已经集成该类库,不用再 ...
- python3.0 day02 列表、元组 、字典、字符串操作
1.列表.元组操作 列表是我们最以后最常用的数据类型之一,通过列表可以对数据实现最方便的存储.修改等操作,类似于其他语言中的数组. 定义列表 names = ['Lioa',"Tenglan ...
- jquery.validate使用 - 4
自定义错误消息的显示方式 默认情况下,验证提示信息用label元素来显示, 并且会添加css class, 通过css可以很方便设置出错控件以及错误信息的显示方式. /* 输入控件验证出错*/form ...
- EmitMapper自动映射工具
在实体与DTO之间,我们一般都需要进行映射.如果手动的来进行转换,实在是太麻烦.所以就产生了很多映射工具,比如AutoMapper,EmitMapper.而经过一些对比,EmitMa ...
- 【Jmeter测试】使用Java请求进行Dubbo接口的测试
如何构建一个Dubbo接口测试的通用框架(https://github.com/nitibu/jmeter-dubbo-test)从上面的流程我们可以看出,测试类大致的一个结构: 使用json文件来 ...
- [寒假学习笔记](二)Python初学
Python 学习 python的自学从几个月前断断续续地进行,想好好利用这个寒假,好好地学一学. 回顾 已学习:基本操作.函数 已有C++的一定基础,只要注意python中比较特殊的部分就行 进入正 ...
- ES6的新特性(15)——Promise 对象
Promise 对象 Promise 的含义 Promise 是异步编程的一种解决方案,比传统的解决方案——回调函数和事件——更合理和更强大.它由社区最早提出和实现,ES6 将其写进了语言标准,统一了 ...
- Cross origin requests are only supported for protocol schemes: http, data, chrome,chrome-extension的问题
Cross origin requests are only supported for protocol schemes: http, data, chrome,chrome-extension的问 ...
- 软工第十二周个人PSP
11.30--12.6本周例行报告 1.PSP(personal software process )个人软件过程. C(类别) C(内容) ST(开始时间) ET(结束时间) INT(间隔时间) Δ ...
- Hadoop环境搭建01
根据马士兵老师的Hadoop进行的配置 1.首先列下来需要用到的软件 VirtulBox虚拟机.Centos7系统镜像.xshell.xftp.jdk安装包.hadoop-2.7.0安装包 2.在Vi ...