Codeforces Beta Round #46 (Div. 2)

http://codeforces.com/contest/49

A

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define maxn 1000005
  8. typedef long long ll;
  9. typedef unsigned long long ull;
  10.  
  11. int main(){
  12. #ifndef ONLINE_JUDGE
  13. freopen("input.txt","r",stdin);
  14. #endif
  15. std::ios::sync_with_stdio(false);
  16. map<char,int>mp;
  17. mp['A']++;
  18. mp['E']++;
  19. mp['I']++;
  20. mp['O']++;
  21. mp['U']++;
  22. mp['Y']++;
  23. mp['a']++;
  24. mp['e']++;
  25. mp['i']++;
  26. mp['o']++;
  27. mp['u']++;
  28. mp['y']++;
  29. string str;
  30. getline(cin,str);
  31. char ch;
  32. for(int i=str.length()-;i>=;i--){
  33. if((str[i]>='A'&&str[i]<='Z')||(str[i]>='a'&&str[i]<='z')){
  34. ch=str[i];
  35. break;
  36. }
  37. }
  38. if(mp[ch]) cout<<"YES"<<endl;
  39. else cout<<"NO"<<endl;
  40. }

B

模拟进制转换和运算

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define maxn 1000005
  8. typedef long long ll;
  9. typedef unsigned long long ull;
  10.  
  11. int getmax(int a){
  12. int Max=;
  13. while(a){
  14. Max=max(a%,Max);
  15. a/=;
  16. }
  17. return Max;
  18. }
  19.  
  20. int Change(int n,int base){
  21. int p=;
  22. int ans=;
  23. while(n){
  24. ans=ans+(n%)*p;
  25. n/=;
  26. p*=base;
  27. }
  28. return ans;
  29. }
  30.  
  31. int main(){
  32. #ifndef ONLINE_JUDGE
  33. // freopen("input.txt","r",stdin);
  34. #endif
  35. std::ios::sync_with_stdio(false);
  36. int a,b;
  37. cin>>a>>b;
  38. int base=max(getmax(a),getmax(b))+;
  39. int sum=Change(a,base)+Change(b,base);
  40. int ans=;
  41. while(sum){
  42. sum/=base;
  43. ans++;
  44. }
  45. cout<<ans<<endl;
  46. }

C

找规律

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define maxn 1000005
  8. typedef long long ll;
  9. typedef unsigned long long ull;
  10.  
  11. int main(){
  12. #ifndef ONLINE_JUDGE
  13. // freopen("input.txt","r",stdin);
  14. #endif
  15. std::ios::sync_with_stdio(false);
  16. int n;
  17. cin>>n;
  18. cout<<n<<" ";
  19. for(int i=;i<n;i++) cout<<i<<" ";
  20. }

D

枚举第一个是0还是1,然后不断向后遍历判断,取最小值

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define maxn 1000005
  8. typedef long long ll;
  9. typedef unsigned long long ull;
  10.  
  11. int n;
  12. string str;
  13.  
  14. int func(int ch){
  15. int ans=;
  16. if(str[]!=ch+'') ans++;
  17. ch^=;
  18. for(int i=;i<str.length();i++){
  19. if(str[i]!=ch+''){
  20. ans++;
  21. }
  22. ch^=;
  23. }
  24. return ans;
  25. }
  26.  
  27. int main(){
  28. #ifndef ONLINE_JUDGE
  29. // freopen("input.txt","r",stdin);
  30. #endif
  31. std::ios::sync_with_stdio(false);
  32. cin>>n;
  33. cin>>str;
  34. int ans=0x3f3f3f3f;
  35. ans=min(ans,func());
  36. ans=min(ans,func());
  37. cout<<ans<<endl;
  38. }

E

区间DP

参考博客:https://blog.csdn.net/zhjchengfeng5/article/details/8201105

  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define lson l,mid,rt<<1
  4. #define rson mid+1,r,rt<<1|1
  5. #define sqr(x) ((x)*(x))
  6. #define pb push_back
  7. #define eb emplace_back
  8. #define maxn 1000005
  9. #define rep(k,i,j) for(int k=i;k<j;k++)
  10. typedef long long ll;
  11. typedef unsigned long long ull;
  12.  
  13. string s[];
  14. int n;
  15. string str[];
  16. int dp[][];
  17. bool book[][][][];
  18. int len[];
  19.  
  20. void Init(int id){
  21. len[id]=s[id].length();
  22. rep(i,,len[id]){
  23. book[id][i][i][s[id][i]-'a']=;
  24. }
  25. rep(L,,len[id]+){
  26. int st=;
  27. rep(en,st+L-,len[id]){
  28. rep(mid,st,en){
  29. rep(i,,n){
  30. if(book[id][st][mid][str[i][]-'a']&&book[id][mid+][en][str[i][]-'a']){
  31. book[id][st][en][str[i][]-'a']=;
  32. }
  33. }
  34. }
  35. st++;
  36. }
  37. }
  38. }
  39.  
  40. int main(){
  41. #ifndef ONLINE_JUDGE
  42. freopen("input.txt","r",stdin);
  43. #endif
  44. std::ios::sync_with_stdio(false);
  45. cin>>s[]>>s[];
  46. cin>>n;
  47. for(int i=;i<n;i++){
  48. cin>>str[i];
  49. }
  50. Init(),Init();
  51. memset(dp,0x3f,sizeof(dp));
  52. dp[][]=;
  53. rep(mid0,,len[]){
  54. rep(mid1,,len[]){
  55. rep(st0,mid0,len[]){
  56. rep(st1,mid1,len[]){
  57. rep(ch,,){
  58. if(book[][mid0][st0][ch]&&book[][mid1][st1][ch]){
  59. dp[st0+][st1+]=min(dp[st0+][st1+],dp[mid0][mid1]+);
  60. }
  61. }
  62. }
  63. }
  64. }
  65. }
  66. int ans=dp[len[]][len[]];
  67. if(ans==0x3f3f3f3f) cout<<-<<endl;
  68. else cout<<ans<<endl;
  69. }

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. MVC基于角色权限控制--用户管理

    用户管理模块包括 新增用户.修改用户.展示用户列表.删除用户.用户角色分配.用户角色删除.用户权限分配 这里只介绍关于权限有关的 用户角色分配.用户角色删除.用户权限分配 新建控制器 UserInfo ...

  2. Human Interface Device (HID) Class Decoder

    http://www.usblyzer.com/usb-human-interface-device-hid-class-decoder.htm   Human Interface Device (H ...

  3. Mac安装Python3报错Permission denied @ dir_s_mkdir - /usr/local/Frameworks

    brew安装Python3时出现的问题: Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks /usr/local/Frame ...

  4. git学习入门

    git: 安装 git是目前最流行的版本管理系统,分为github(公共开源,代码可随意下载)和gitlib(私有化,企业使用).

  5. sendfile函数--零拷贝(转)

    零拷贝:零拷贝技术可以减少数据拷贝和共享总线操作的次数,消除通信数据在存储器之间不必要的中间拷贝过程,有效地提高通信效率,是设计高速接口通道.实现高速服务器和路由器的关键技术之一. sendfile ...

  6. 转:jquery操作元素的css样式(获取、修改等等)

    //1.获取和设置样式 $("#tow").attr("class")获取ID为tow的class属性 $("#two").attr(&qu ...

  7. [CI]CodeIgniter系统流程

    ---------------------------------------------------------------------------------------------------- ...

  8. A*寻路初探(转载)

    启发式搜索:启发式搜索就是在状态空间中的搜索对每一个搜索的位置进行评估,得到最好的位置,再从这个位置进行搜索直到目标.这样可以省略大量无畏的搜索路径,提到了效率.在启发式搜索中,对位置的估价是十分重要 ...

  9. 手动安裝TMG2010所需Windows服务和功能

    安装 Forefront TMG 之前,必须运行准备工具,以验证是否已在您的计算机上安装成功安装 Forefront TMG 所需的应用程序.如果在未首先运行准备工具的情况下运行 Forefront ...

  10. 编程四剑客sed-2019.2.20

    sed    [-Options]     [‘Commands’]    filename; sed工具默认处理文本,文本内容输出屏幕已经修改,但是文件内容其实没有修改,需要加-i参数即对文件彻底修 ...