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 ...
随机推荐
- IIS asp 401.1错误
asp程序使用非匿名帐户运行时因用户名前带了计算机名会导致出现401.1错误,只要直接输入用户名即可,不要带计算机名.
- 使用pt-table-checksum及pt-table-sync校验复制一致性
一.简介 pt-table-checksum是percona-toolkit系列工具中的一个, 可以用来检测主. 从数据库中数据的一致性.其原理是在主库上运行, 对同步的表进行checksum, 记录 ...
- C# DataTable使用方法详解--删除表数据
在项目中常常常使用到DataTable,假设DataTable使用得当,不仅能使程序简洁有用,并且可以提高性能,达到事半功倍的效果,现对DataTable的使用技巧进行一下总结. 1.添加引用 1 u ...
- rhel7磁盘管理
一.MBR主引导记录 MBR有512个字节,分为三个部分:第一部分446个字节,存储了引导分区:第二部分64字节为分区表:第三部分2个字节结束符:每个分区需16个字节,所以MBR的模式 ...
- 阿里云栖大会 所有ppt
https://github.com/Alimei/hangzhouYunQi2017ppt
- SAP 费用
SAP在华真相:天价收费与用户之灾 SAP真的是企业实施ERP系统的最佳选择吗? 画皮SAP-世界管理软件公司的中国真相 你知道SAP吗?哦,知道,满大街都是嘛,S-P-A,SPA.做出上述回答的是一 ...
- tomcat 启动报错 Invalid character found in method name. HTTP method names must be tokens
解决:Invalid character found in method name. HTTP method names must be tokens 阿里云上弄了一个tomcat,经常半夜发送崩 ...
- linux 系统 网卡 ethX没有显示IP的处理方式
1 临时方式 ifconfig 设备名 IP 地址 (ifconfig eth0 192.168.1.117) 设置好之后马上生效,不需要重启网卡服务(千万别重启网卡服务,不然刚刚设置的又没有了) ...
- 修改php.ini 的timezone
php运行模式有apache 和 cli模式 这里讲cli 模式的php.ini设置 1.查找php.ini位置 php -i | grep php.ini 这样是表示 要改的文件 在/etc/php ...
- ssh架构之hibernate(二)进阶学习
1.JPA入门 JPA的认识:JPA全称Java Persistence API.JPA通过JDK 5.0注解或XML描述对象-关系表的映射关系,并将运行期的实体对象持久化到数据库中Java持久层AP ...