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. 我要带徒弟学写JAVA架构,引路架构师之路(Jeecg开源社区)

    带徒弟学JAVA架构(Jeecg社区)      Java程序员如何打破工作2,3年的瓶颈问题,如何更上一层楼?      太多的巧合,让我接触到了开源,通过JEECG与很多朋友交流后,让我有了帮助别 ...

  2. Linux kafka 单机安装

    Kafka地址(选择最新地址1.1.1) http://archive.apache.org/dist/kafka/

  3. Java,AWTUtilities,eclipse报编译错误:Access restriction: The type 'AWTUtilities' is not API (restriction on required library 'C:\Program Files\Java\jre7\lib\rt.jar')

    [场景]调用com.sun.awt.AWTUtilities时,eclipse提示编译错误: Access restriction: The type 'AWTUtilities' is not AP ...

  4. webstorm设置自定义代码快捷键

    1.file——>setting——>Editor——>live Templates出现如下界面 2.点击左上角绿色+选择template group创建分组(图中React Vue ...

  5. vue:绑定数据的vue页面加载会闪烁问题

    1:在挂在数据的容器加上属性 v-cloak 2:在css中添加如下代码 但有时候还是会不起作用,可能原因有两个 2.1:display属性被更高权限的display属性覆盖了,我们增加权限就好了 2 ...

  6. JS基础一-入门知识

    一.什么是JavaScript JavaScript是一种基于对象和事件驱动并具有安全性能的解释性脚本语言.JavaScript不需要编译,直接嵌入在HTTP页面中,把静态页面转变成支持用户交互并响应 ...

  7. JSON数据的解析和生成(Swift)

    Codable public typealias Codable = Decodable & Encodable public protocol Decodable {} public pro ...

  8. python 函数返回值笔记

    今天学习python时候学习到闭包和柯里化 感觉看概念时候不好理解,自己写下大概就明白点了 柯里化如下 定义一个加法函数 def add(x, y): return x + y 这是没有柯里化之前的函 ...

  9. 检查浏览器是否已经启用Java支持功能

    <script type="text/javascript"> document.write("navigator对象的方法"+"< ...

  10. ANg-别人家的笔记

    http://blog.csdn.net/scruelt/article/details/78997697 https://github.com/fengdu78/Coursera-ML-Andrew ...