a

【问题描述】
你是能看到第一题的 friends 呢。
——hja
给你一个只有小括号和中括号和大括号的括号序列,问该序列是否合法。
【输入格式】
一行一个括号序列。
【输出格式】
如果合法,输出 OK,否则输出 Wrong。
【样例输入】
[(])
【样例输出】
Wrong
【数据范围与规定】
70%的数据,1 ≤ ? ≤ 100。
对于100%的数据,1 ≤ ? ≤ 10000,所有单词由大写字母组成。

#include<iostream>
#include<cstring>
#include<cstdio>
#define maxn 10010
using namespace std;
int top;
char ch[maxn],st[maxn];
int main(){
//freopen("Cola.txt","r",stdin);
freopen("a.in","r",stdin);freopen("a.out","w",stdout);
scanf("%s",ch+);
int len=strlen(ch+);
for(int i=;i<=len;i++){
if(ch[i]=='('||ch[i]=='['||ch[i]=='{')st[++top]=ch[i];
else if(ch[i]==')'){
if(top==||st[top]!='('){
printf("Wrong");
return ;
}
else top--;
}
else if(ch[i]==']'){
if(top==||st[top]!='['){
printf("Wrong");
return ;
}
else top--;
}
else if(ch[i]=='}'){
if(top==||st[top]!='{'){
printf("Wrong");
return ;
}
else top--;
}
}
if(top!=)printf("Wrong");
else printf("OK");
fclose(stdin);fclose(stdout);
return ;
}

100分 栈模拟

b

【问题描述】
你是能看到第二题的 friends 呢。
——laekov
Yjq 想要将一个长为?宽为?的矩形棺材(棺材表面绝对光滑,所以棺材可
以任意的滑动)拖过一个 L 型墓道。
如图所示,L 型墓道两个走廊的宽度分别是?和?,呈 90°,并且走廊的长
度远大于?。
现在 Hja 想知道对于给定的?,?,?,最大的?是多少,如果无论如何棺材都
不可能通过,则输出"My poor head =("
【输入格式】
第一行三个用空格分隔的整数?,?,?,意义如题目所示。
【输出格式】
输出最大的可能的?,保留七位小数,如果无论如何棺材都不可能通过,则
输出"My poor head =("。
【样例输入 1】
2 2 1
【样例输出 1】
1.0000000
P100 zhxb
第 4 页 共 5 页
【样例输入 2】
2 2 2
【样例输出 2】
2.0000000
【样例输入 3】
2 2 3
【样例输出 3】
1.3284271
【样例输入 4】
2 2 6
【样例输出 4】
My poor head =(
【数据范围与规定】
对于100%的数据,1 ≤ ?,?,? ≤ 10 4 。

#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
int a,b,l;
double q,e,ans;
int main(){
freopen("b.in","r",stdin);freopen("b.out","w",stdout);
scanf("%d%d%d",&a,&b,&l);
q=sqrt(a*a+b*b);
e=l*1.0/;
ans=min(double(l),q-e);
if(l<=b)ans=max(ans,min(double(a),double(l)));
if(ans<)printf("My poor head =(");
else printf("%.7lf",ans);
fclose(stdin);fclose(stdout);
return ;
}

18分 乱搞

/*
两种情况:
1.在拐角处被卡:以最左下角的点为原点,用矩形与坐标轴相交的两个点可以求出矩形一边的直线的方程,通过右上方点到这个直线的距离可以求出此时的宽度,然后可以转换成一个以宽度为因变量的函数,这个函数是一个单峰函数,用三分求解
2.在拐角处垂直向上移动,直接输出b
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int a,b,l;
double get(double v1)
{
double v2=sqrt(l*l-v1*v1);
if (a*v1+b*v2<v1*v2) return -1e+;
else return (a*v1+b*v2-v1*v2)/l;
}
int main()
{
freopen("b.in","r",stdin);
freopen("b.out","w",stdout);
scanf("%d%d%d",&a,&b,&l);
if (a>=l && b>=l) printf("%d.0000000\n",l);
else
{
if (a>=l) printf("%d.0000000\n",b);
else
{
if (b>=l) printf("%d.0000000\n",a);
else
{
double lv=0.0,rv=l;
for (int c=;c<=;c++)
{
double m1=(rv-lv)/3.0+lv;
double m2=lv+rv-m1;
if (get(m1)<0.0 || get(m2)<0.0)
{
printf("My poor head =(\n");
return ;
}
if (get(m1)<get(m2)) rv=m2;
else lv=m1;
}
printf("%.7lf\n",get(rv));
}
}
}
return ;
}

100分 三分

c

【问题描述】
你是能看到第三题的 friends 呢。
——aoao
树是个好东西,删掉树一条边要 1 的代价,随便再加一条边有 1 的代价,求
最小的代价把树变成环。
【输入格式】
第一行一个整数?,代表树的点数。
接下来? − 1行,每行两个数代表树的一条边。
【输出格式】
一行一个整数代表答案。
【样例输入】
4
1 2
2 3
2 4
【样例输出】
3
【数据规模与约定】
3。
60%的数据,1 ≤ ? ≤ 10。
对于100%的数据,1 ≤ ? ≤ 100000。

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100010
using namespace std;
int n,num,ans,root;
int into[MAXN],head[MAXN];
struct node{
int to,pre;
}e[MAXN*];
void add(int from,int to){
e[++num].to=to;
e[num].pre=head[from];
head[from]=num;
}
void dfs(int now,int fa){
for(int i=head[now];i;i=e[i].pre){
int to=e[i].to;
if(to!=fa){
dfs(to,now);
if(into[to]>){
into[now]--;
ans+=(into[to]-)*;
}
}
}
}
int main(){
freopen("c.in","r",stdin);freopen("c.out","w",stdout);
scanf("%d",&n);
for(int i=;i<n;i++){
int u,v;
scanf("%d%d",&u,&v);
add(u,v);add(v,u);
into[u]++;
into[v]++;
}
root=;
for(int i=;i<=n;i++)
if(into[i]==){
root=i;
break;
}
dfs(root,-);
cout<<ans+;
}

100分 贪心+暴力

2017-10-3 清北刷题冲刺班p.m的更多相关文章

  1. 2017-10-4 清北刷题冲刺班p.m

    P102zhx a [问题描述]你是能看到第一题的 friends 呢.——hja两种操作:1.加入一个数.2.询问有多少个数是?的倍数.[输入格式]第一行一个整数?,代表操作数量.接下来?行,每行两 ...

  2. 2017-10-4 清北刷题冲刺班a.m

    P101zhx a [问题描述]你是能看到第一题的 friends 呢.——hjaHja 拥有一套时光穿梭技术,能把字符串以超越光速的速度传播,但是唯一的问题是可能会 GG.在传输的过程中,可能有四种 ...

  3. 2017-10-3 清北刷题冲刺班a.m

    P99zhx a [问题描述]你是能看到第一题的 friends 呢.——hja怎么快速记单词呢?也许把单词分类再记单词是个不错的选择.何大爷给出了一种分单词的方法,何大爷认为两个单词是同一类的当这两 ...

  4. 2017-10-2 清北刷题冲刺班a.m

    一道图论神题 (god) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带权图,只 ...

  5. 2017-10-2 清北刷题冲刺班p.m

    最大值 (max) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK有一本书,上面有很多有趣的OI问题.今天LYK看到了这么一道题目: 这里有一个长度为n ...

  6. 2017-10-1 清北刷题冲刺班p.m

    一道图论好题 (graph) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK有一张无向图G={V,E},这张无向图有n个点m条边组成.并且这是一张带权图 ...

  7. 2017-10-7 清北刷题冲刺班p.m

    测试 A 同花顺 文件名 输入文件 输出文件 时间限制 空间限制card.cpp/c/pas card.in card.out 1s 512MB题目描述所谓同花顺,就是指一些扑克牌,它们花色相同,并且 ...

  8. 2017-10-7 清北刷题冲刺班a.m

    测试 A 消失的数字 文件名 输入文件 输出文件 时间限制 空间限制del.cpp/c/pas del.in del.out 1s 512MB题目描述现在,我的手上有 n 个数字,分别是 a 1 ,a ...

  9. 2017-10-1 清北刷题冲刺班a.m

    位运算1 (bit) Time Limit:1000ms   Memory Limit:128MB 题目描述 LYK拥有一个十进制的数N.它赋予了N一个新的意义:将N每一位都拆开来后再加起来就是N所拥 ...

随机推荐

  1. ES doc_values的来源,field data——就是doc->terms的正向索引啊,不过它是在查询阶段通过读取倒排索引loading segments放在内存而得到的?

    Support in the Wild: My Biggest Elasticsearch Problem at Scale Java Heap Pressure Elasticsearch has ...

  2. Cuckoo hash算法分析——其根本思想和bloom filter一致 增加hash函数来解决碰撞 节省了空间但代价是查找次数增加

    基本思想: cuckoo hash是一种解决hash冲突的方法,其目的是使用简单的hash 函数来提高hash table的利用率,同时保证O(1)的查询时间 基本思想是使用2个hash函数来处理碰撞 ...

  3. PHP 常量、PHP 变量全解析(超全局变量、变量的8种数据类型等)

    常量特点 常量一旦被定义就无法更改或撤销定义. 常量名不需要开头的$ 与变量不同,常量贯穿整个脚本是自动全局的. 作用域不影响对常量的访问 常量值只能是字符串或数字 设置 PHP 常量 如需设置常量, ...

  4. hdu-5651 xiaoxin juju needs help(数学+gcd约分求阶乘)

    题目链接: xiaoxin juju needs help Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K ...

  5. linux命令学习笔记(15):tail 命令

    tail 命令从指定点开始将文件写到标准输出.使用tail命令的-f选项可以方便的查阅正在改变的日志文件, tail -f filename会把filename里最尾部的内容显示在屏幕上,并且不但刷新 ...

  6. FFMPEG内存操作(一) avio_reading.c 回调读取数据到内存解析

    相关博客列表 : FFMPEG内存操作(一) avio_reading.c 回调读取数据到内存解析 FFMPEG内存操作(二)从内存中读取数及数据格式的转换 FFmpeg内存操作(三)内存转码器 在F ...

  7. bzoj 2594: 水管局长数据加强版 Link-Cut-Tree

    题目: Description SC省MY市有着庞大的地下水管网络,嘟嘟是MY市的水管局长(就是管水管的啦),嘟嘟作为水管局长的工作就是:每天供水公司可能要将一定量的水从x处送往y处,嘟嘟需要为供水公 ...

  8. [Codeforces 204E] Little Elephant and Strings

    [题目链接] https://codeforces.com/contest/204/problem/E [算法] 首先构建广义后缀自动机 对于自动机上的每个节点 , 维护一棵平衡树存储所有它所匹配的字 ...

  9. 迁移学习-微调(fine-tune)的注意事项:

    选取微调形式的两个重要因素:新数据集的大小(size)和相似性(与预训练的数据集相比).牢记卷积网络在提取特征时,前面的层所提取的更具一般性,后面的层更加具体,更倾向于原始的数据集(more orig ...

  10. ssh配置免登 Ubuntu环境

    配置之前,可能需要修改下每台机器的hostname,修改方法 1.直接修改hostname文件:sudo vi /etc/hostname 2.重启服务器:shutdown -r now Ubuntu ...