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)的更多相关文章

  1. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  2. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  3. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  4. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  5. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  6. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  7. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  8. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

  9. Codeforces Beta Round #72 (Div. 2 Only)

    Codeforces Beta Round #72 (Div. 2 Only) http://codeforces.com/contest/84 A #include<bits/stdc++.h ...

随机推荐

  1. Spring Cloud (3)B Ribbon 负载均衡 IRule

    package com.service.config; import com.netflix.loadbalancer.IRule;import com.netflix.loadbalancer.Ra ...

  2. day3 python 阿狸的进阶之路

    函数概念: 1.为什要有函数 组织结构不清晰,可读性差,代码冗余,可扩展性差. 2.什么是函数   具备某一个功能的工具--->函数     事先准备工具->函数的定义     拿来就用. ...

  3. openGL-------------别人的博客

    https://blog.csdn.net/dcrmg/article/category/6505957 OpenGL(一)绘制圆.五角星.正弦曲线 ========================= ...

  4. python 机器学习实践入门

    机器学习概念概念 机器 学习是计算机科学的一个分支,从模式识别.人工智能和计算学习理论发展而来,我们可以将其作为数据挖掘的工具 侧重用于数据分析方法理解给定的数据 目的是:开发能够从先前观测的数据,通 ...

  5. Go的50度灰:Golang新开发者要注意的陷阱和常见错误(转)

    目录 [−] 初级 开大括号不能放在单独的一行 未使用的变量 未使用的Imports 简式的变量声明仅可以在函数内部使用 使用简式声明重复声明变量 偶然的变量隐藏Accidental Variable ...

  6. 使用DDOS deflate抵御少量DDOS攻击

    DDoS-Deflate是一款非常小巧的防御和减轻DDoS攻击的工具,它可以通过监测netstat来跟踪来创建大量互联网连接的IP地址信息,通过APF或IPTABLES禁止或阻档这些非常IP地址. 工 ...

  7. springmvc简单教程

    IDEA建立Spring MVC Hello World 详细入门教程(转自)   引子,其实从.NET转Java已经有几个月时间了,项目也做了不少,但是很多配置都是根据公司模板或者网上教程比忽略画瓢 ...

  8. Linux find命令使用方法

      Linux中find命令用来在指定目录下查找文件.通过组合不同参数可以在linux系统中快速查找需要的文件或目录. find命令语法 格式:find pathname -options [ -pr ...

  9. PHP 操作Mongodb 实例

    缩略版本<?php //1.连接MongoDB $mongo = new Mongo(); $mongo = new Mongo("mongodb://username:passwor ...

  10. ADO.Net 数据库查询

    数据库中的表: VS查询代码: using System; using System.Collections.Generic; using System.Linq; using System.Text ...