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 ...
随机推荐
- python关于文件的一些记录
1.文件打开: file("data.txt")或open("data.txt")注意不要漏了文件的后缀.(不加参数时,file为你默认为'r',reading ...
- c8051单片机注意事项:
一定要注意交叉开关问题:外设要想正确分配到指定引脚,一定要用配置工具确定分配到指定引脚:如果手动分配一定要仔细验证.这方面有个深刻的教训. 有个项目用c8051f020,用到2个串口,硬件已经确定好了 ...
- Linux--NiaoGe-Service-01
安装环境介绍 CentOS 6.9_x86_64 我们选择的是基本安装,也即“Basic Server”. 安装完成后重启来到(runlevel 3)纯文本界面. 例题 批量创建账号:假设有5个账号x ...
- [BZOJ1053][SDOI2005]反素数ant 数学
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1053 假设这个最大的反素数为$x$,那么$1<p<x$中数的因子数都没有$x$ ...
- checkbox:click事件触发span元素内容改变
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- 利用伪类写一个自定义checkbox和radio
首先是效果图来一张 再来一张html结构 关键的CSS来了~ 首先呢要把input标签设置为display: none; 因为自定义的原理是通过label的for属性,来点击label转向为点击in ...
- js获取上周、本周、下周的时间
//获取上周起始时间结束时间.下周起始时间结束时间开始时间和本周起始时间结束时间;(西方) function getTime(n) { var now = new Date(); var year = ...
- 固定table表头
<style> #box{ height:214px; width:500px; overflow-y:auto;/** 必须,否则当表格数据过多时,不会产生滚动条,而是自动延长该div的 ...
- dede网站目录权限设置
如果你的网站数据十分重要(那种两天就能弄好的垃圾站就算了),建议按本文所说的安全步骤进行严格的设置.1.目录权限 我们不建议用户把栏目目录设置在根目录, 原因是这样进行安全设置会十分的麻烦, 在默认的 ...
- [Python學習筆記] 使用xlwings 插入註解 (forked 版本)
到今天為止 xlwings 還沒有插入註解的功能 去原始開發者的 Github Pull Requests 他說之前有人有建議要加入這個功能 但他還沒更新~ 如果需要使用 Python 來插入註解的話 ...