Codeforces Beta Round #46 (Div. 2)
Codeforces Beta Round #46 (Div. 2)
http://codeforces.com/contest/49
A
#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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
map<char,int>mp;
mp['A']++;
mp['E']++;
mp['I']++;
mp['O']++;
mp['U']++;
mp['Y']++;
mp['a']++;
mp['e']++;
mp['i']++;
mp['o']++;
mp['u']++;
mp['y']++;
string str;
getline(cin,str);
char ch;
for(int i=str.length()-;i>=;i--){
if((str[i]>='A'&&str[i]<='Z')||(str[i]>='a'&&str[i]<='z')){
ch=str[i];
break;
}
}
if(mp[ch]) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
B
模拟进制转换和运算
#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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; int getmax(int a){
int Max=;
while(a){
Max=max(a%,Max);
a/=;
}
return Max;
} int Change(int n,int base){
int p=;
int ans=;
while(n){
ans=ans+(n%)*p;
n/=;
p*=base;
}
return ans;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int a,b;
cin>>a>>b;
int base=max(getmax(a),getmax(b))+;
int sum=Change(a,base)+Change(b,base);
int ans=;
while(sum){
sum/=base;
ans++;
}
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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
int n;
cin>>n;
cout<<n<<" ";
for(int i=;i<n;i++) cout<<i<<" ";
}
D
枚举第一个是0还是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 maxn 1000005
typedef long long ll;
typedef unsigned long long ull; int n;
string str; int func(int ch){
int ans=;
if(str[]!=ch+'') ans++;
ch^=;
for(int i=;i<str.length();i++){
if(str[i]!=ch+''){
ans++;
}
ch^=;
}
return ans;
} int main(){
#ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>n;
cin>>str;
int ans=0x3f3f3f3f;
ans=min(ans,func());
ans=min(ans,func());
cout<<ans<<endl;
}
E
区间DP
参考博客:https://blog.csdn.net/zhjchengfeng5/article/details/8201105
#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 eb emplace_back
#define maxn 1000005
#define rep(k,i,j) for(int k=i;k<j;k++)
typedef long long ll;
typedef unsigned long long ull; string s[];
int n;
string str[];
int dp[][];
bool book[][][][];
int len[]; void Init(int id){
len[id]=s[id].length();
rep(i,,len[id]){
book[id][i][i][s[id][i]-'a']=;
}
rep(L,,len[id]+){
int st=;
rep(en,st+L-,len[id]){
rep(mid,st,en){
rep(i,,n){
if(book[id][st][mid][str[i][]-'a']&&book[id][mid+][en][str[i][]-'a']){
book[id][st][en][str[i][]-'a']=;
}
}
}
st++;
}
}
} int main(){
#ifndef ONLINE_JUDGE
freopen("input.txt","r",stdin);
#endif
std::ios::sync_with_stdio(false);
cin>>s[]>>s[];
cin>>n;
for(int i=;i<n;i++){
cin>>str[i];
}
Init(),Init();
memset(dp,0x3f,sizeof(dp));
dp[][]=;
rep(mid0,,len[]){
rep(mid1,,len[]){
rep(st0,mid0,len[]){
rep(st1,mid1,len[]){
rep(ch,,){
if(book[][mid0][st0][ch]&&book[][mid1][st1][ch]){
dp[st0+][st1+]=min(dp[st0+][st1+],dp[mid0][mid1]+);
}
}
}
}
}
}
int ans=dp[len[]][len[]];
if(ans==0x3f3f3f3f) cout<<-<<endl;
else cout<<ans<<endl;
}
Codeforces Beta Round #46 (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 ...
随机推荐
- PHPExcel在TP下使用
第一:你要去PHPExcel官网下载,然后放到网站的Vendor文件夹下面.当然这是为了好管理和导入.你放在其他位置也没有关系. 第二:当然是在你需要的地方写代码.我只写样例,你看懂了就可以灵活的使用 ...
- Jquery 属性选择器&设置元素属性
什么是属性选择器呢?感觉理解起来有点难,举个例子就很容易明白了,<div id="ajaxa"></div>这里的id就是属性,这下就很容易理解了, jqu ...
- react-native 安卓支持 gif动态图
需要在android/app/build.gradle文件中添加模块 //这一行没有的话得加上才行 compile "com.facebook.fresco:fresco:1.5.0&quo ...
- linux 组管理
修改文件所有者 chown 用户名 文件名 修改文件所在的组 chgrp 组名 文件名 r = 4 , w = 2, x = 2 u :所有者 g :所在组 o:其他组 a: ...
- 页面中href链接的碰撞
问题: 如上图动态生成一个li列表,点击之后页面直接全部刷新了一遍 原因: 动态生成的代码(第一个图)中href链接地址与顶部页面(上图)中固定的href链接存在冲突 如果动态生成的列表指定的链接名称 ...
- debian9 下编译安装tengine2.2.1
首先下载tengine的源码包,这个大家都会下载吧 wget http://tengine.taobao.org/download/tengine-2.2.1.tar.gz 然后解压缩 tar zxf ...
- Idea使用Maven异常 --- Maven网络代理设置
在conf/setting.xml和m2/repository/setting.xml中加入: <proxies> <!-- proxy | Specification for on ...
- python 小整数池 和intern 【整理】
小整数对象池 (在python内置了) 整数在程序中的使用非常广泛,Python为了优化速度,使用了小整数对象池,避免为整数频繁申请和销毁内存空间. Python对小整数的定义是[-5,257]这些整 ...
- python基础学习Day17 面向对象的三大特性之继承、类与对象名称空间小试
一.课前回顾 类:具有相同属性和方法的一类事物 实例化:类名() 过程: 开辟了一块内存空间 执行init方法 封装属性 自动的把self返回给实例化对象的地方 对象:实例 一个实实在在存在的实体 组 ...
- Repeater - 重复器
Repeater - 重复器,用来展示泛型集合中的数据 五大模板:1.HeaderTemplate - 头模板,加载时会在开始执行一次2.FooterTemplate - 脚模板,加载时会在最后执行一 ...