A题,无聊的题目。

  1. #include <cstdio>
  2. #include <string>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <cstdlib>
  6. #include <ctime>
  7. #include <queue>
  8. #include <vector>
  9. #include <map>
  10. #include <set>
  11. #include <algorithm>
  12. #include <iostream>
  13. using namespace std;
  14. set<string>st;
  15. int main()
  16. {
  17. char str[];
  18. int i,ans,temp,len;
  19. ans = ;
  20. temp = ;
  21. while(gets(str) != )
  22. {
  23. len = strlen(str);
  24. if(str[] == '+')
  25. {
  26. st.insert(str);
  27. temp ++;
  28. }
  29. else if(str[] == '-')
  30. {
  31. st.erase(str);
  32. temp --;
  33. }
  34. else
  35. {
  36. for(i = ;i < len;i ++)
  37. {
  38. if(str[i] == ':') break;
  39. }
  40. ans += (len - i - )*temp;
  41. }
  42. }
  43. printf("%d\n",ans);
  44. return ;
  45. }

B题,无聊题目,1Y.

  1. #include <cstdio>
  2. #include <string>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <cstdlib>
  6. #include <ctime>
  7. #include <queue>
  8. #include <vector>
  9. #include <map>
  10. #include <set>
  11. #include <algorithm>
  12. #include <iostream>
  13. using namespace std;
  14. char str[][];
  15. int main()
  16. {
  17. int n,i,j,maxz,len,mod,st,z;
  18. //freopen("a.txt","r",stdin);
  19. maxz = ;
  20. i = ;
  21. while(gets(str[i]) != )
  22. {
  23. len = strlen(str[i++]);
  24. maxz = max(len,maxz);
  25. }
  26. n = i;
  27. mod = maxz%;
  28. for(i = ;i <= maxz+;i ++)
  29. printf("*");
  30. printf("\n");
  31. z = ;
  32. for(i = ;i < n;i ++)
  33. {
  34. printf("*");
  35. len = strlen(str[i]);
  36. if(len% == mod)
  37. {
  38. st = (maxz - len)/;
  39. }
  40. else
  41. {
  42. st = (maxz - len)/ + z;
  43. z = (z+)%;
  44. }
  45. for(j = ;j < st;j ++)
  46. {
  47. printf(" ");
  48. }
  49. for(;j < len+st;j ++)
  50. printf("%c",str[i][j-st]);
  51. for(;j < maxz;j ++)
  52. printf(" ");
  53. printf("*\n");
  54. }
  55. for(i = ;i <= maxz+;i ++)
  56. printf("*");
  57. printf("\n");
  58. return ;
  59. }

C题,乱搞题,我用栈找到左右括号对应的位置,然后再从头扫一边,利用这个标记,找到最长的。怀疑有可能超时,但还是过了。

  1. #include <cstdio>
  2. #include <string>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <cstdlib>
  6. #include <ctime>
  7. #include <queue>
  8. #include <vector>
  9. #include <map>
  10. #include <set>
  11. #include <algorithm>
  12. #include <iostream>
  13. using namespace std;
  14. char str[];
  15. int s[];
  16. int flag[];
  17. int main()
  18. {
  19. int len,i,top,maxz,ans,temp,dis;
  20. scanf("%s",str);
  21. len = strlen(str);
  22. top = ;
  23. maxz = ;
  24. ans = ;
  25. for(i = ;i < len;i ++)
  26. {
  27. if(str[i] == ')')
  28. {
  29. if(top == ) continue;
  30. top --;
  31. flag[s[top]] = i;
  32. }
  33. else
  34. {
  35. s[top++] = i;
  36. }
  37. }
  38. for(i = ;i < len;i ++)
  39. {
  40. temp = i;
  41. dis = ;
  42. if(maxz > len - i + ) break;
  43. while(str[temp] == '(')
  44. {
  45. if(!flag[temp]) break;
  46. dis += flag[temp] - temp + ;
  47. temp = flag[temp] + ;
  48. if(temp == len) break;
  49. }
  50. if(dis == ) continue;
  51. if(maxz < dis)
  52. {
  53. maxz = dis;
  54. ans = ;
  55. }
  56. else if(maxz == dis)
  57. ans ++;
  58. }
  59. printf("%d %d\n",maxz,ans);
  60. return ;
  61. }

D题,物理题,被题意绕了一下,注意只有d点限速,不是某一段路限速。然后就是各种if else 各种算。。

  1. #include <cstdio>
  2. #include <string>
  3. #include <cstring>
  4. #include <cmath>
  5. #include <cstdlib>
  6. #include <ctime>
  7. #include <queue>
  8. #include <vector>
  9. #include <map>
  10. #include <set>
  11. #include <algorithm>
  12. #include <iostream>
  13. using namespace std;
  14. int main()
  15. {
  16. double a,v,l,d,w;
  17. double t1,t2,s1,s2,t3,s3;
  18. scanf("%lf%lf%lf%lf%lf",&a,&v,&l,&d,&w);
  19. if(w >= v)
  20. {
  21. t1 = v*1.0/a;
  22. s1 = 0.5*a*t1*t1;
  23. if(s1 > l)
  24. {
  25. printf("%.8lf\n",sqrt(*l*1.0/a));
  26. }
  27. else
  28. {
  29. printf("%.8lf\n",t1 + (l-s1)/v);
  30. }
  31. }
  32. else
  33. {
  34. t1 = w*1.0/a;
  35. s1 = 0.5*a*t1*t1;
  36. if(s1 > d)
  37. {
  38. t1 = v*1.0/a;
  39. s1 = 0.5*a*t1*t1;
  40. if(s1 > l)
  41. {
  42. printf("%.8lf\n",sqrt(*l*1.0/a));
  43. }
  44. else
  45. {
  46. printf("%.8lf\n",t1 + (l-s1)/v);
  47. }
  48. }
  49. else
  50. {
  51. t1 = v/a;
  52. s1 = 0.5*a*t1*t1;
  53. t2 = (v-w)/a;
  54. s2 = (v+w)/*t2;
  55. double v0;
  56. if(s1+s2 > d)
  57. {
  58. v0 = sqrt(a*(d +(w*w//a)));
  59. t2 = v0/a + (v0-w)/a;
  60. }
  61. else
  62. {
  63. t2 = t1 + t2 + (d-s1-s2)/v;
  64. }
  65. t3 = (v-w)/a;
  66. s3 = w*t3 + 0.5*a*t3*t3;
  67. if(s3 > l-d)
  68. {
  69. t3 = (-w+sqrt(w*w+*a*(l-d)))/a;
  70. printf("%.8lf\n",t3+t2);
  71. }
  72. else
  73. {
  74. printf("%.8lf\n",t3+t2+(l-d-s3)/v);
  75. }
  76. }
  77. }
  78. return ;
  79. }

E题,留坑吧。托了好久,想了错的思路。看了题解,两种做法,都是把最大的找出来,转化成链,然后用栈做,怎么做的,我也没看明白。

还有一种就是标记左边第一个大的l,右边第一个大的r,然后l-r之间有多少个相同的。就能求一个位置的对数了。

Codeforces Beta Round #5的更多相关文章

  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 #62 题解【ABCD】

    Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...

  3. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

  4. Codeforces Beta Round #13 C. Sequence (DP)

    题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...

  5. Codeforces Beta Round #79 (Div. 2 Only)

    Codeforces Beta Round #79 (Div. 2 Only) http://codeforces.com/contest/102 A #include<bits/stdc++. ...

  6. Codeforces Beta Round #77 (Div. 2 Only)

    Codeforces Beta Round #77 (Div. 2 Only) http://codeforces.com/contest/96 A #include<bits/stdc++.h ...

  7. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #75 (Div. 2 Only)

    Codeforces Beta Round #75 (Div. 2 Only) http://codeforces.com/contest/92 A #include<iostream> ...

  9. Codeforces Beta Round #74 (Div. 2 Only)

    Codeforces Beta Round #74 (Div. 2 Only) http://codeforces.com/contest/90 A #include<iostream> ...

  10. Codeforces Beta Round #73 (Div. 2 Only)

    Codeforces Beta Round #73 (Div. 2 Only) http://codeforces.com/contest/88 A 模拟 #include<bits/stdc+ ...

随机推荐

  1. IIS7 经典模式和集成模式的区别(转载)

    转载地址:http://www.poluoluo.com/server/201301/193110.html 升级过程中出现了比较多的问题,前面文章也提到过几个.这次就主要介绍下httpHandler ...

  2. Swing布局基础

    虽然很简单,但还是记录一下,以备复查. 1.BorderLayout ,这是JFrame的默认布局方式,基于此的新组件,例如BUTTON,可以放在东西南北中的某一个位置,如果不指定,则默认是中央.中央 ...

  3. Solr auto commit 配置

    为了解决写索引时频繁提交带来的效率问题,考虑使用自动提交. 在solrconfig.xml中增加以下代码: <updateHandler class="solr.DirectUpdat ...

  4. Linux命令之ar - 创建静态库.a文件和动态库.so

    转自:http://blog.csdn.net/eastonwoo/article/details/8241693 用途说明 创建静态库.a文件.用C/C++开发程序时经常用到,但我很少单独在命令行中 ...

  5. VMware报错:“device eth0 does not seem to be present, delaying initialization ”

    转自:http://blog.sina.com.cn/s/blog_77126fa501018s3d.html vmlite虚拟机启动出错,就把这个虚拟机删除掉重新建立,系统虚拟硬盘使用之前的,启动系 ...

  6. Codeforces Round #369 (Div. 2) D. Directed Roads dfs求某个联通块的在环上的点的数量

    D. Directed Roads   ZS the Coder and Chris the Baboon has explored Udayland for quite some time. The ...

  7. dojo.publish 和 dojo.subscribe

    原文链接:http://www.cnblogs.com/didi/archive/2010/06/13/1757894.html //dojo.publish 和 dojo.subscribe  :d ...

  8. BroadCast,BroadCastReceiver

    效果是:一个MainActivity动态注册一个BroadcastReceiver,BActivity发送一个标准广播,MainActivity接收到广播后,将广播中的消息显示在MainActivit ...

  9. window系统查看端口被哪个进程占用了

    C:\netstat -aon|findstr 8080TCP 127.0.0.1:80 0.0.0.0:0 LISTENING 2448端口被进程号为2448的进程占用,继续执行下面命令:C:\ta ...

  10. DSP using MATLAB示例 Example3.5

    代码: n = [0:10]; x = (0.9*exp(j*pi/3)).^n; % x(n) = k = -200:200; w = (pi/100)*k; % [0,pi] axis divid ...