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

  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. 抛出异常 exception

    throw raise raise Exception.CreateFmt(sFileWithNoExt, [FileName]);

  2. 学习opengl第一步

    有两个地址一个是学习opengl基础知识的网站, 一个是博客园大牛分享的特别好的文章. 记录一下希望向坚持做俯卧撑一样坚持下去. 学习网站:http://learnopengl-cn.readthed ...

  3. +load +initialize

    +load方法 在app启动的时候各个类的+load方法都会被调用,+load方法不是通过消息机制调用的,它是直接调用的,因此无论是在子类或者category中复写此方法,复写的+load方法都会被调 ...

  4. Delphi Qjson

    使用QJSON解析数据: JSon 字符串: {"Code":1,"Msg":"", "Data":[{"Ne ...

  5. SQL SERVER 2000安装遇到的问题小汇总(转载)

    [1]安装程序配置服务器失败需要修改下注册表1 打开注册表 在"开始"--"运行"键入 "regedit"  2 删除注册表如下键值: HK ...

  6. Linux命令:unzip

    语法: unzip [-Z] [-opts[modifiers]] file[.zip] [list] [-x xlist] [-d exdir] 默认行为将zip文件中的内容全部解压缩到当前目录下. ...

  7. oc字符串与c字符串转换和拷贝

    // Helper method to create C string copy NSString* MakeNSString (const char* string) { if (string) { ...

  8. HTML实现页面自动跳转的五种方法

    下面列了五个例子来详细说明,这几个例子的主要功能是:在5秒后,自动跳转到同目录下的hello.html(根据自己需要自行修改)文件. 1)html的实现 复制代码 代码如下: <head> ...

  9. ReactiveX 学习笔记(19)使用 RxSwift + RxCocoa 进行 GUI 编程

    课题 程序界面由3个文本编辑框和1个文本标签组成. 要求文本标签实时显示3个文本编辑框所输入的数字之和. 文本编辑框输入的不是合法数字时,将其值视为0. 3个文本编辑框的初值分别为1,2,3. 创建工 ...

  10. [PC]PHPCMS二次开发指南(上)

    ------------------------------------------------------------------------------------- PHPCMS本身功能已经很完 ...