CodeForces 20 A+B
A - BerOS file system
水题不解释了,压缩斜杆。要注意最后没有斜杠。
char a[105];
int main()
{
// int t,n;
while(~scanf("%s",a))
{ int len=strlen(a);
int k=len-1;
while(a[k]=='/'&&k>=0) k--;
if(k<0)
{
printf("/\n");
continue;
}
int f=0;
for(int i=0;i<k+1;i++)
{
if(a[i]=='/'&&f)
continue;
else printf("%c",a[i]);
f=0;
if(a[i]=='/') f=1;
}
printf("\n");
} return 0;
}
B - Equation
Ax2 + Bx + C = 0
给定A,B,C判断有无根,递增输出其根。
注意无限根与无根的前提下对开方里数的进行判断即可。
int main()
{
double a,b,c;
while(~scanf("%lf%lf%lf",&a,&b,&c))
{
if(a==b&&b==c&&c==0)
{
printf("-1\n");//无限根;
continue;
}
double x=b*b-a*4*c;
if(((a==0&&b==0)&&c!=0)||x<0)
{
printf("0\n");
continue;
}
if(x==0)
{
double xx=-b/(2.0*a);
printf("1\n%.5f\n",xx);
continue;
}
if(a==0)
{
double xx=-c/b;
printf("1\n%.5f\n",xx);
continue;
}
double x1=(-b+sqrt(x))/(2.0*a);
double x2=(-b-sqrt(x))/(2.0*a);
if(x1>x2) swap(x1,x2);
if(x1==x2)
printf("1\n%.5f\n",x1);
else printf("2\n%.5f\n%.5f\n",x1,x2);
} return 0;
}
CodeForces 20 A+B的更多相关文章
- Codeforces Alpha Round #20 (Codeforces format) C. Dijkstra?(裸的dijkstra)
题目链接:http://codeforces.com/problemset/problem/20/C 思路:需要用优化过的dijkstra,提供两种写法. #include <iostream& ...
- Educational Codeforces Round 20
Educational Codeforces Round 20 A. Maximal Binary Matrix 直接从上到下从左到右填,注意只剩一个要填的位置的情况 view code //#pr ...
- 7.20 Codeforces Beta Round #8
链接:codeforces.com/contest/8 A 原因:RE,fantasy 的字符串的长度可能大于原字符串. B 题意:上下左右走,可能要避让障碍,问是否存在一个地图使得给定的路径为当前最 ...
- 2018.9.20 Educational Codeforces Round 51
蒟蒻就切了四道水题,然后EF看着可写然而并不会,中间还WA了一次,我太菜了.jpg =.= A.Vasya And Password 一开始看着有点虚没敢立刻写,后来写完第二题发现可以暴力讨论,因为保 ...
- Educational Codeforces Round 20 C(math)
題目鏈接: http://codeforces.com/problemset/problem/803/C 題意: 給出兩個數n, k, 將n拆分成k個數的和,要求這k個數是嚴格遞增的,並且這k個數的g ...
- 【20.23%】【codeforces 740A】Alyona and copybooks
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【20.51%】【codeforces 610D】Vika and Segments
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Educational Codeforces Round 20.C
C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...
- Educational Codeforces Round 20 C 数学/贪心/构造
C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...
随机推荐
- servlet生命周期:
Servlet生命周期分为三个阶段: 1,初始化阶段 servlet实例创建时调用init()方法,在Servlet的整个生命周期内,init()方法只被调用一次. 2,响应客户请求阶段 调用ser ...
- CSS实现文字旋转/实现角标
主要用到属性transform:rotate(-30deg) example: .divedittable .project-tag div { width: 43px; line-height: 4 ...
- php多文件上传类(含示例)
在网上看到一个比较好的多文件上传类,自己改良了下,顺便用js实现了多文件浏览,php文件上传原理都是相同的,多文件上传也只是进行了循环上传而已,当然你也可以使用swfupload进行多文件上传! &l ...
- [转]Linq 如何实现 in 与 not in
本文转自:http://blog.csdn.net/zhangyumei/article/details/5620363 接触 LINQ 也有很长的一段时间了,有些在 SQL 语句中用的很顺手的东西在 ...
- java实现网络监听
Java实现网络监听 import java.net.*; import java.io.*; public class tcpServer { public static void main(Str ...
- 初用emmet
下载emmet的pspad插件emmet.js.复制到pspad目录下的 script\JScript 文件夹. 输入 ul#nav>li.item$*4>{Item $} 但是没反应. ...
- df - 报告文件系统磁盘空间的使用情况
总览 df [OPTION]... [FILE]... POSIX 选项: [-kP] GNU 选项 (最短方式): [-ahHiklmPv] [-t fstype] [-x fstype] [--b ...
- @click.native 会触发原生 click事件 vue
@click.native 会触发原生 click事件 vue
- 暑假集训 || 概率DP
Codeforces 148D 考虑状态转移..https://www.cnblogs.com/kuangbin/archive/2012/10/04/2711184.html题意:原来袋子里有w只白 ...
- ie8不支持伪类选择器的解决方案
引用jQuery的插件jquery.pseudo.js插件内容: (function($){ var patterns = { text: /^['"]?(.+?)["']?$/, ...