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 ...
随机推荐
- 那些年用过的Redis集群架构
今天我们来谈谈Redis集群这个话题,需要说明的是本文 适合人群:不知道自己生产redis集群架构,以及对Redis集群不了解的人 不适合群: 对自己生产Redis集群架构非常了解的人 本文预计分两个 ...
- C++11之for循环的新用法《转》
相关资料:https://legacy.gitbook.com/book/changkun/cpp1x-tutorial/details C++11之for循环的新用法 C++使用如下方法遍历一个容器 ...
- APP-3-百度地图应用
1.百度地图开发平台 http://lbsyun.baidu.com/ 1.1申请账号 1.2Android创建应用 进入百度地图开发平台->控制台->创建应用 发布版SHA1:BA:AD ...
- pgsql restart
/etc/init.d/postgresql restart
- Pythagorean Triples 707C
Katya studies in a fifth grade. Recently her class studied right triangles and the Pythagorean theor ...
- 如何查看一个class文件是否正确
今天碰到了个问题,左思右想就是找不出问题,试验多个路径来解决问题,错误依旧. 然后我拿到了现场的包,一个很大的问题让我忽略了,这个class文件用反编译程序打不开(jd-gui.exe),非常神奇,但 ...
- html中,纯数字或纯英文的一串字符超出父容器不会折行显示,如何解决?
这种情况在软件使用过程中一般不会出现,只有测试人员在测试的时候手比较贱会给你弄一个这种数据,当然这也算是bug吧. 如图:“经营范围”的值严重超出父容器长度,并且没有像“服务信息”一样折行显示.这种情 ...
- css3的2D和3D的转换
一:2D转换: 通过 CSS3 transform转换,我们能够对元素进行移动.缩放.转动.拉长或拉伸. 2D移动:translate().使用translate()函数,你可以把元素从原来的位置移 ...
- VC++ 中ListCtrl经验总结
先注明一下,这里,我们用m_listctrl来表示一个CListCtrl的类对象,然后这里我们的ListCtrl都是report形式,至于其他的如什么大图标,小图标的暂时不讲,毕竟report是大众话 ...
- 修改maven项目的编译版本
在pom.xml中添加如下代码 <build> <!-- 配置了很多插件 --> <plugins> <plugin> <groupId>o ...