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. 设计模式学习之策略模式(Strategy,行为型模式)(13)

    转载地址:http://www.cnblogs.com/zhili/p/StragetyPattern.html 一.引言 本文要介绍的策略模式也就是对策略进行抽象,策略的意思就是方法,所以也就是对方 ...

  2. gcc【数学几何】

    GCC Time Limit: 1000MS Memory limit: 65536K 题目描述 The GNU Compiler Collection (usually shortened to G ...

  3. K-MEANS算法总结

    K-MEANS算法 摘要:在数据挖掘中,K-Means算法是一种 cluster analysis 的算法,其主要是来计算数据聚集的算法,主要通过不断地取离种子点最近均值的算法. 在数据挖掘中,K-M ...

  4. C# 将文件转化成byte[]数组

    /// <summary> /// 将文件转换成byte[] 数组 /// </summary> /// <param name="fileUrl"& ...

  5. js判断当前的访问是手机还是电脑

    <script type="text/javascript"> //平台.设备和操作系统 var system ={ win : false, mac : false, ...

  6. 难得的中文ASP.NET 5/MVC 6入门教程

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:由于ASP.NET 5还未正式发布,即使是官方文档都还不完善,更不要说系统的中文文档了 ...

  7. DTMF的原理分析

    转自:http://blog.csdn.net/wangwenwen/article/details/8264925 1. DTMF原理 DTMF(Double Tone MulitiFrequenc ...

  8. Java中的异或(转)

    在java程序里面的异或用法: 相同输出0,不同输出1,例如: System.out.println(1^1); 输出0 System.out.println(1^2):输出3,因为最后2个低位都不一 ...

  9. zoj 3471(状态压缩)

    题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=4257 dp[state]表示当前状态为state时的所能获得的最大值 ...

  10. Android Manifest 权限描述大全

    权限 名称 描述 android.permission.ACCESS_CHECKIN_PROPERTIES 访问登记属性 读取或写入登记check-in数据库属性表的权限 android.permis ...