Codeforces Beta Round #5
A题,无聊的题目。
- #include <cstdio>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #include <queue>
- #include <vector>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- set<string>st;
- int main()
- {
- char str[];
- int i,ans,temp,len;
- ans = ;
- temp = ;
- while(gets(str) != )
- {
- len = strlen(str);
- if(str[] == '+')
- {
- st.insert(str);
- temp ++;
- }
- else if(str[] == '-')
- {
- st.erase(str);
- temp --;
- }
- else
- {
- for(i = ;i < len;i ++)
- {
- if(str[i] == ':') break;
- }
- ans += (len - i - )*temp;
- }
- }
- printf("%d\n",ans);
- return ;
- }
B题,无聊题目,1Y.
- #include <cstdio>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #include <queue>
- #include <vector>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- char str[][];
- int main()
- {
- int n,i,j,maxz,len,mod,st,z;
- //freopen("a.txt","r",stdin);
- maxz = ;
- i = ;
- while(gets(str[i]) != )
- {
- len = strlen(str[i++]);
- maxz = max(len,maxz);
- }
- n = i;
- mod = maxz%;
- for(i = ;i <= maxz+;i ++)
- printf("*");
- printf("\n");
- z = ;
- for(i = ;i < n;i ++)
- {
- printf("*");
- len = strlen(str[i]);
- if(len% == mod)
- {
- st = (maxz - len)/;
- }
- else
- {
- st = (maxz - len)/ + z;
- z = (z+)%;
- }
- for(j = ;j < st;j ++)
- {
- printf(" ");
- }
- for(;j < len+st;j ++)
- printf("%c",str[i][j-st]);
- for(;j < maxz;j ++)
- printf(" ");
- printf("*\n");
- }
- for(i = ;i <= maxz+;i ++)
- printf("*");
- printf("\n");
- return ;
- }
C题,乱搞题,我用栈找到左右括号对应的位置,然后再从头扫一边,利用这个标记,找到最长的。怀疑有可能超时,但还是过了。
- #include <cstdio>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #include <queue>
- #include <vector>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- char str[];
- int s[];
- int flag[];
- int main()
- {
- int len,i,top,maxz,ans,temp,dis;
- scanf("%s",str);
- len = strlen(str);
- top = ;
- maxz = ;
- ans = ;
- for(i = ;i < len;i ++)
- {
- if(str[i] == ')')
- {
- if(top == ) continue;
- top --;
- flag[s[top]] = i;
- }
- else
- {
- s[top++] = i;
- }
- }
- for(i = ;i < len;i ++)
- {
- temp = i;
- dis = ;
- if(maxz > len - i + ) break;
- while(str[temp] == '(')
- {
- if(!flag[temp]) break;
- dis += flag[temp] - temp + ;
- temp = flag[temp] + ;
- if(temp == len) break;
- }
- if(dis == ) continue;
- if(maxz < dis)
- {
- maxz = dis;
- ans = ;
- }
- else if(maxz == dis)
- ans ++;
- }
- printf("%d %d\n",maxz,ans);
- return ;
- }
D题,物理题,被题意绕了一下,注意只有d点限速,不是某一段路限速。然后就是各种if else 各种算。。
- #include <cstdio>
- #include <string>
- #include <cstring>
- #include <cmath>
- #include <cstdlib>
- #include <ctime>
- #include <queue>
- #include <vector>
- #include <map>
- #include <set>
- #include <algorithm>
- #include <iostream>
- using namespace std;
- int main()
- {
- double a,v,l,d,w;
- double t1,t2,s1,s2,t3,s3;
- scanf("%lf%lf%lf%lf%lf",&a,&v,&l,&d,&w);
- if(w >= v)
- {
- t1 = v*1.0/a;
- s1 = 0.5*a*t1*t1;
- if(s1 > l)
- {
- printf("%.8lf\n",sqrt(*l*1.0/a));
- }
- else
- {
- printf("%.8lf\n",t1 + (l-s1)/v);
- }
- }
- else
- {
- t1 = w*1.0/a;
- s1 = 0.5*a*t1*t1;
- if(s1 > d)
- {
- t1 = v*1.0/a;
- s1 = 0.5*a*t1*t1;
- if(s1 > l)
- {
- printf("%.8lf\n",sqrt(*l*1.0/a));
- }
- else
- {
- printf("%.8lf\n",t1 + (l-s1)/v);
- }
- }
- else
- {
- t1 = v/a;
- s1 = 0.5*a*t1*t1;
- t2 = (v-w)/a;
- s2 = (v+w)/*t2;
- double v0;
- if(s1+s2 > d)
- {
- v0 = sqrt(a*(d +(w*w//a)));
- t2 = v0/a + (v0-w)/a;
- }
- else
- {
- t2 = t1 + t2 + (d-s1-s2)/v;
- }
- t3 = (v-w)/a;
- s3 = w*t3 + 0.5*a*t3*t3;
- if(s3 > l-d)
- {
- t3 = (-w+sqrt(w*w+*a*(l-d)))/a;
- printf("%.8lf\n",t3+t2);
- }
- else
- {
- printf("%.8lf\n",t3+t2+(l-d-s3)/v);
- }
- }
- }
- return ;
- }
E题,留坑吧。托了好久,想了错的思路。看了题解,两种做法,都是把最大的找出来,转化成链,然后用栈做,怎么做的,我也没看明白。
还有一种就是标记左边第一个大的l,右边第一个大的r,然后l-r之间有多少个相同的。就能求一个位置的对数了。
Codeforces Beta Round #5的更多相关文章
- 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 #62 题解【ABCD】
Codeforces Beta Round #62 A Irrational problem 题意 f(x) = x mod p1 mod p2 mod p3 mod p4 问你[a,b]中有多少个数 ...
- 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 #13 C. Sequence (DP)
题目大意 给一个数列,长度不超过 5000,每次可以将其中的一个数加 1 或者减 1,问,最少需要多少次操作,才能使得这个数列单调不降 数列中每个数为 -109-109 中的一个数 做法分析 先这样考 ...
- 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+ ...
随机推荐
- IIS7 经典模式和集成模式的区别(转载)
转载地址:http://www.poluoluo.com/server/201301/193110.html 升级过程中出现了比较多的问题,前面文章也提到过几个.这次就主要介绍下httpHandler ...
- Swing布局基础
虽然很简单,但还是记录一下,以备复查. 1.BorderLayout ,这是JFrame的默认布局方式,基于此的新组件,例如BUTTON,可以放在东西南北中的某一个位置,如果不指定,则默认是中央.中央 ...
- Solr auto commit 配置
为了解决写索引时频繁提交带来的效率问题,考虑使用自动提交. 在solrconfig.xml中增加以下代码: <updateHandler class="solr.DirectUpdat ...
- Linux命令之ar - 创建静态库.a文件和动态库.so
转自:http://blog.csdn.net/eastonwoo/article/details/8241693 用途说明 创建静态库.a文件.用C/C++开发程序时经常用到,但我很少单独在命令行中 ...
- VMware报错:“device eth0 does not seem to be present, delaying initialization ”
转自:http://blog.sina.com.cn/s/blog_77126fa501018s3d.html vmlite虚拟机启动出错,就把这个虚拟机删除掉重新建立,系统虚拟硬盘使用之前的,启动系 ...
- 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 ...
- dojo.publish 和 dojo.subscribe
原文链接:http://www.cnblogs.com/didi/archive/2010/06/13/1757894.html //dojo.publish 和 dojo.subscribe :d ...
- BroadCast,BroadCastReceiver
效果是:一个MainActivity动态注册一个BroadcastReceiver,BActivity发送一个标准广播,MainActivity接收到广播后,将广播中的消息显示在MainActivit ...
- window系统查看端口被哪个进程占用了
C:\netstat -aon|findstr 8080TCP 127.0.0.1:80 0.0.0.0:0 LISTENING 2448端口被进程号为2448的进程占用,继续执行下面命令:C:\ta ...
- 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 ...