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的更多相关文章

  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. ASP.NET Web API 上传文件

    HTML表单: <form id="form1" method="post" enctype="multipart/form-data" ...

  2. 【JAVA集合框架之Set】

    一.Set概述. Set集合的特点是元素不允许重复,而且是无序的(添加和取出的顺序不一致). Set接口中的方法和Collection接口中的方法几乎相同,略. Set接口下常用的两个类:HashSe ...

  3. win7Java开发环境配置

    win7下Java开发环境的配置 首先下载符合操作系统版本的jdk,比如最新的jdk8: 下载链接:http://www.oracle.com/technetwork/java/javase/down ...

  4. php+jquery+ajax实现用户名验证

    大多数情况下,jquery代码的编写,都要求我们将jquery的代码放在以下三种中任一个function里. 有三种写法,同样效果,有点像Window.onload,但也有不同,就是window.on ...

  5. [Skills] 在桌面打开一个BAT文件,CMD窗口不关闭

    每次开机都要取得本机IP,然后远程连接上去,屏幕太小,不好输入,想写个bat,执行就能看到IP,并且停留在cmd窗口上,想来简单,以前搜了好久没找到好的办法,今天找到一个贴子,竟然可以,呵呵!   以 ...

  6. Linux系统启动流程及安装命令行版本

    Debian安装 之前也安装过很多次linux不同版本的系统,但安装后都是直接带有桌面开发环境的版本,直接可以使用,正好最近项目不是很忙,想一直了解下Linux的整个启动流程,以及如何从命令行模式系统 ...

  7. C++Primer快速浏览笔记-类型转换

    bool b = 42; // _b is true_ int i = b; // _i has value 1_ i = 3.14; // _i has value 3_ double pi = i ...

  8. HDU 3727 Jewel 可持久化线段树

    Jewel Problem Description   Jimmy wants to make a special necklace for his girlfriend. He bought man ...

  9. 【hibernate】 hibernate的主键策略

    今天使用maven生成一个sping+springMVC+hibernate 的项目,报错如下: 错误提示呢:不能解释这个id的生成策略[uuid.string].就是uuid.string这个hib ...

  10. ThinkPHP3.2 volist嵌套循环显示原理

    php页面:$fatherList = $Document->where('pid=1')->select();        foreach($fatherList as $n=> ...