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 ...
随机推荐
- MVC基于角色权限控制--用户管理
用户管理模块包括 新增用户.修改用户.展示用户列表.删除用户.用户角色分配.用户角色删除.用户权限分配 这里只介绍关于权限有关的 用户角色分配.用户角色删除.用户权限分配 新建控制器 UserInfo ...
- Human Interface Device (HID) Class Decoder
http://www.usblyzer.com/usb-human-interface-device-hid-class-decoder.htm Human Interface Device (H ...
- Mac安装Python3报错Permission denied @ dir_s_mkdir - /usr/local/Frameworks
brew安装Python3时出现的问题: Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks /usr/local/Frame ...
- git学习入门
git: 安装 git是目前最流行的版本管理系统,分为github(公共开源,代码可随意下载)和gitlib(私有化,企业使用).
- sendfile函数--零拷贝(转)
零拷贝:零拷贝技术可以减少数据拷贝和共享总线操作的次数,消除通信数据在存储器之间不必要的中间拷贝过程,有效地提高通信效率,是设计高速接口通道.实现高速服务器和路由器的关键技术之一. sendfile ...
- 转:jquery操作元素的css样式(获取、修改等等)
//1.获取和设置样式 $("#tow").attr("class")获取ID为tow的class属性 $("#two").attr(&qu ...
- [CI]CodeIgniter系统流程
---------------------------------------------------------------------------------------------------- ...
- A*寻路初探(转载)
启发式搜索:启发式搜索就是在状态空间中的搜索对每一个搜索的位置进行评估,得到最好的位置,再从这个位置进行搜索直到目标.这样可以省略大量无畏的搜索路径,提到了效率.在启发式搜索中,对位置的估价是十分重要 ...
- 手动安裝TMG2010所需Windows服务和功能
安装 Forefront TMG 之前,必须运行准备工具,以验证是否已在您的计算机上安装成功安装 Forefront TMG 所需的应用程序.如果在未首先运行准备工具的情况下运行 Forefront ...
- 编程四剑客sed-2019.2.20
sed [-Options] [‘Commands’] filename; sed工具默认处理文本,文本内容输出屏幕已经修改,但是文件内容其实没有修改,需要加-i参数即对文件彻底修 ...