Codeforces Beta Round #40 (Div. 2)
Codeforces Beta Round #40 (Div. 2)
http://codeforces.com/contest/41
A
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxn 1000006 int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string s1,s2;
cin>>s1>>s2;
if(s1.length()==s2.length()){
for(int i=;i<s1.length();i++){
if(s1[i]!=s2[s1.length()-i-]){
cout<<"NO"<<endl;
return ;
}
}
cout<<"YES"<<endl;
return ;
}
cout<<"NO"<<endl;
}
B
贪心,每种情况枚举过去,买的话建一个优先队列存最小值
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define maxn 1000006 int a[];
int c[][];
int n,b; int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>b;
for(int i=;i<=n;i++) cin>>a[i];
int ans=b;
priority_queue<int,vector<int>, greater<int> >Q;
Q.push(a[]);
for(int i=;i<=n;i++){
int tmp=b;
vector<int>ve;
ve.clear();
for(int j=;j<i;j++){
if(!Q.empty()&&tmp>Q.top()){
ve.push_back(Q.top());
ans=max(ans,tmp/Q.top()*a[i]+tmp%Q.top());
tmp%=Q.top();
}
}
Q.push(a[i]);
for(int j=;j<ve.size();j++){
Q.push(ve[j]);
}
}
cout<<ans<<endl;
}
C
模拟
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eps 1e-8
#define PI acos(-1.0)
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull; /*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
string str;
cin>>str;
cout<<str[];
int flag=;
for(int i=;i<str.length();i++){
if(str[i]=='d'&&i<str.length()-){
if(str[i+]=='o'&&str[i+]=='t'){
cout<<'.';
i+=;
}
else{
cout<<str[i];
}
}
else if(str[i]=='a'){
if(str[i+]=='t'&&!flag){
cout<<'@';
flag=;
i++;
}
else{
cout<<str[i];
}
}
else{
cout<<str[i];
}
}
}
D
DP
有句话说的好,DP不行,再加一维。。。
加上的那一维为到该点的值
复杂度为O(n*m*9*n)
注意,0也算是k+1的倍数
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eps 1e-8
#define PI acos(-1.0)
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull; /*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */
int n,m,kk;
string str[];
bool dp[][][];
short pre[][][]; void dfs(int floor,int pos,int v){
if(floor==n-){
cout<<pos+<<endl;
return;
}
dfs(floor+,pre[floor][pos][v],v-(str[floor][pos]-''));
if(pre[floor][pos][v]<pos){
cout<<'R';
}
else{
cout<<'L';
}
} int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n>>m>>kk;
for(int i=;i<n;i++) cin>>str[i];
for(int i=;i<m;i++){
dp[n-][i][str[n-][i]-'']=;
}
for(int i=n-;i>=;i--){
for(int j=;j<m;j++){
for(int k=;k<=;k++){
if(dp[i+][j][k]){
if(j->=){
dp[i][j-][k+str[i][j-]-'']=;
pre[i][j-][k+str[i][j-]-'']=j;
}
if(j+<m){
dp[i][j+][k+str[i][j+]-'']=;
pre[i][j+][k+str[i][j+]-'']=j;
}
}
}
}
}
int Max=-;
int pos=;
for(int i=;i<m;i++){
for(int j=;j>=;j--){
if((dp[][i][j]==)&&(j%(kk+)==)){
if(Max<j){
Max=j;
pos=i;
}
}
}
}
if(Max==-){
cout<<-<<endl;
return ;
}
cout<<Max<<endl;
dfs(,pos,Max);
}
E
找规律,题意说不存在3的循环,所以可以把图看成二分图
边的总数为:(n/2)*(n/2+n%2)
#include<bits/stdc++.h>
using namespace std;
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define sqr(x) ((x)*(x))
#define pb push_back
#define eps 1e-8
#define PI acos(-1.0)
#define maxn 1000005
typedef long long ll;
typedef unsigned long long ull; /*#ifndef ONLINE_JUDGE
freopen("1.txt","r",stdin);
#endif */ int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
if(n==){
cout<<<<endl;
}
else if(n==){
cout<<<<endl;
cout<<"1 2"<<endl;
}
else{
cout<<(n/)*(n/+n%)<<endl;
for(int i=;i<=n/;i++){
for(int j=n/+;j<=n;j++){
cout<<i<<" "<<j<<endl;
}
}
}
}
Codeforces Beta Round #40 (Div. 2)的更多相关文章
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
- Codeforces Beta Round #79 (Div. 2 Only)
Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...
- Codeforces Beta Round #77 (Div. 2 Only)
Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #75 (Div. 2 Only)
Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...
- Codeforces Beta Round #74 (Div. 2 Only)
Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...
- Codeforces Beta Round #73 (Div. 2 Only)
Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...
- Codeforces Beta Round #72 (Div. 2 Only)
Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...
随机推荐
- vue父子组件嵌套的时候遇到 - Component template should contain exactly one root element. If you are using v-i
转自:https://blog.csdn.net/yangyiboshigou/article/details/72084619
- 如何创建一个django工程与和mysql打通
1. 安装Django # 在指定解释器环境下安装django 1.11.x # 在真实python3环境下: pip3 install django==1.11.x # 查看django版本: dj ...
- idea debug只断点当前线程,不阻塞其他线程
公司前后端分离,后端人员无需编写前端js ,后端开发调试某个数据的时候,前端总是嫌弃后端断点,影响到他开发.....idea早已提供这个功能,做下记录 选中你需要调试的控制器,其他控制器不会受到影响, ...
- Net操作Excel_NPOI
Npoi 简介 1.整个Excel表格叫做工作表:WorkBook(工作薄),包含的叫页(工作表):Sheet:行:Row:单元格Cell. 2.Npoi 下载地址:http://npoi.codep ...
- python模块os
一.os模块概述 Python os模块包含普遍的操作系统功能.如果你希望你的程序能够与平台无关的话,这个模块是尤为重要的.(一语中的) 二.常用方法 1.os.name 输出字符串指示正在使用的平台 ...
- Unity系列文章
1.IoC模式:http://www.cnblogs.com/qqlin/archive/2012/10/09/2707075.html 这篇博客是通过一个播放器的例子来说明什么是依赖,依赖倒置,控 ...
- WPF 中关于 DataTemplateSelector 类的应用
MSDN的解释: 提供一种根据数据对象和与该数据绑定的元素来选择数据模板 DataTemplate 的方法. 示例代码: <Window x:Class="WpfApplication ...
- python安装与IO编程
<python爬虫开发与项目实战>基础篇(一) 一.python安装 1.python IDLE 下载官网:www.python.org 注:在选择安装组件时勾选所有组件,特别注意勾选pi ...
- 基于docker的wekan部署
镜像地址: https://hub.docker.com/r/wekanteam/wekan/ wiki: https://github.com/wekan/wekan/wiki#Developmen ...
- Excel批量修改文件
[1]把下图片放在一个文件目录下面,如E:\SVM_Class\airplanes [2]点击“开始”→“运行”(或按快捷键win+R),在弹出框中输入“cmd”,进入dos操作界面. [3]do ...