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 ...
随机推荐
- mysql 累加求和
; SELECT temp.*,(@csum := total + @csum) as csums from ( ) as total,month(openedDate) as date from z ...
- GitHub创建个人主页
在GitHub,一个项目对应唯一的Git版本库,创建一个新的版本库就是创建一个新的项目.访问仪表板(Dashboard)页面,如图3-1,可以看 到关注的版本库中已经有一个,但自己的版本库为零.在显示 ...
- javascript的DOM操作获取元素
一.document.getElementById() 根据Id获取元素节点 <div id="div1"> <p id="p1"> ...
- CC攻击与DDOS攻击区别
二者的攻击方式主要分为三种:直接攻击.代理攻击.僵尸网络攻击 CC攻击是DDOS(分布式拒绝服务)的一种,相比其它的DDOS攻击CC似乎更有技术含量一些.这种攻击你见不到虚假IP,见不到特别大的异常流 ...
- linux 内核中一个全局变量引发的性能问题
为了调试一个功能,在一个内核模块中,增加了一个全局变量,用来统计自有skb池的申请情况. 因为是临时增加,所以没有考虑性能,一开始只是一个fail的统计,数量不多,也不太考虑是否有计数丢失的情况,毕竟 ...
- 灵活控制 Hibernate 的日志或 SQL 输出,以便于诊断
我们在使用 Hibernate 时一般只会关注是否显示生成的 SQL 语句,不过有些时候还不够.默认时 Hibernate 执行的 SQL 语句是打印在控制台上的,它也可以配置为输出给 Log4J 或 ...
- TypeScript语言学习笔记(1)
基本类型 // 布尔型(Boolean) let isDone: boolean = false; // 数值型(Number) let decimal: number = 6; let hex: n ...
- C++ new 和malloc 区别
1.分配地方不同,malloc是堆上面,new是自由存储区域 2.malloc/delete是函数,new/delete是操作符,可以重载 3.malloc 要指定大小,返回的是void*指针,开辟的 ...
- C#调用C++
c++ extern "C" __declspec(dllexport) char* WINAPI base64_decode( char *data,char base[]) { ...
- 手机移动端web前端常见问题整理
移动端常见问题及解决方案 一.meta基础知识 H5页面窗口自动调整到设备宽度,并禁止用户缩放页面 <meta name="viewport" content="w ...