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 ...
随机推荐
- Ubuntu下无法使用Secure_CRT连接服务器
虚拟机使用 1 .指令安装了SSH服务器 sudo apt-get install openssh-server 2. 输入命令 ps | grep ssh 查看SSH服务是否开启 显示服务已开启 3 ...
- SSO单点登录、跨域重定向、跨域设置Cookie、京东单点登录实例分析
最近在研究SSO单点登录技术,其中有一种就是通过js的跨域设置cookie来达到单点登录目的的,下面就已京东商城为例来解释下跨域设置cookie的过程 涉及的关键知识点: 1.jquery ajax跨 ...
- RADIDE MultiPaste
RADIDE MultiPaste https://community.embarcadero.com/blogs/entry/multipaste-in-the-rad-studio-ide htt ...
- Project2016下载安装密钥激活教程破解
project2016发布增加了许多功能.Microsoft Office 2016 官方正式版发布!这是微软发布的全新办公软件套件,相比现有Office 2013的变化也不是很大,界面和功能都只是微 ...
- 【平台兼容性】jeecg3.7 兼容weblogic 部署改造方案
MyEclipse 配置 WebLogic 10.3.3请参考: https://my.oschina.net/aini3884/blog/895689 常见问题: 1. problem: cvc-e ...
- MySQL主从同步机制及同步中的问题处理
http://www.drupal001.com/2012/03/mysql-master-slave-troubles/ http://www.jb51.net/article/33052.htm
- maven使用fingbugs插件
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>findbugs-maven-plu ...
- elasticsearch-java异常
1. Unsupported major.minor version 52.0 java的jdk版本过低导致,需要更换为jdk1.8+ 2. elasticsearch 的version在pom中提示 ...
- python multithread task_done
queue.task_done()用在queue消费者中,在queue.get()调用之后调用queue.task_done()用于通知队列已经完成了工作,使queue.join()知道任务已经完成. ...
- Kibana安装与基本用法(ELK)
强制使用smtp 465端口加密发送邮件: vim kibana.yml 添加如下: sentinl: settings: email: active: true user: wjoyxt@.com ...