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

  1. Codeforces Alpha Round #20 (Codeforces format) C. Dijkstra?(裸的dijkstra)

    题目链接:http://codeforces.com/problemset/problem/20/C 思路:需要用优化过的dijkstra,提供两种写法. #include <iostream& ...

  2. Educational Codeforces Round 20

    Educational Codeforces Round 20  A. Maximal Binary Matrix 直接从上到下从左到右填,注意只剩一个要填的位置的情况 view code //#pr ...

  3. 7.20 Codeforces Beta Round #8

    链接:codeforces.com/contest/8 A 原因:RE,fantasy 的字符串的长度可能大于原字符串. B 题意:上下左右走,可能要避让障碍,问是否存在一个地图使得给定的路径为当前最 ...

  4. 2018.9.20 Educational Codeforces Round 51

    蒟蒻就切了四道水题,然后EF看着可写然而并不会,中间还WA了一次,我太菜了.jpg =.= A.Vasya And Password 一开始看着有点虚没敢立刻写,后来写完第二题发现可以暴力讨论,因为保 ...

  5. Educational Codeforces Round 20 C(math)

    題目鏈接: http://codeforces.com/problemset/problem/803/C 題意: 給出兩個數n, k, 將n拆分成k個數的和,要求這k個數是嚴格遞增的,並且這k個數的g ...

  6. 【20.23%】【codeforces 740A】Alyona and copybooks

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  7. 【20.51%】【codeforces 610D】Vika and Segments

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. Educational Codeforces Round 20.C

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

  9. Educational Codeforces Round 20 C 数学/贪心/构造

    C. Maximal GCD time limit per test 1 second memory limit per test 256 megabytes input standard input ...

随机推荐

  1. Linux下mysql新建账号及权限设置各种方式总结

    来自:http://justcoding.iteye.com/blog/1941116 1.权限赋予 说明:mysql部署在服务器A上,内网上主机B通过客户端工具连接服务器A以进行数据库操作,需要服务 ...

  2. 【C#】枚举

    枚举 public static class CommonEnums { public enum people { /// <summary> ///男人 /// </summary ...

  3. [转]彻底明确怎样设置minSdkVersion和targetSdkVersion

    minSdkVersion和targetSdkVersion相信非常多人都不太理解.我在网上也看了很多关于这两者差别的文章,感觉说的都非常模糊.直到我在stackOverFlow看到Android M ...

  4. yum install perl-ExtUtils-MakeMaker

    Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/per ...

  5. 登录脚本重构Element

    登录脚本重构Element package com.gubai.selenium; import org.openqa.selenium.By; import org.openqa.selenium. ...

  6. SQLite与MySQL、SQLServer等异构数据库之间的数据同步

    SQLite DBSync是开源嵌入式数据库SQLite的数据同步引擎,实现了SQLite与SQLite数据库之间以及SQLite与异构数据库(Oracle.MySQL.SQLServer)之间的增量 ...

  7. Vue 在beaforeCreate时获取data中的数据

    众所周知,vue在beforecreate时期是获取不到data中的 数据的 但是通过一些方法可以实现在beforecreate时获取到data中的数据 暂时想到两种放发可以实现,vue在before ...

  8. linux下的基础操作

    Xfce 终端: Linux 命令行终端,打开后会进入 zsh Shell 环境,可以使用 Linux 命令. NetSurf 网络浏览器:浏览器,可以用在需要前端界面的课程里,只需要打开环境里写的 ...

  9. hard fault 学习记录

    使用 segger 的 hard fault 的源文件后,当调试时,发生硬件错误的时候,可以查看 HardFaultRegs 中的内容,并对比 segger_HardFaultHandler.c 中的 ...

  10. 二叉排序树BST

    注意:对一个二叉排序树进行中序遍历时,得到的序列是一个按值从小到大排列的有序序列 查找性能的分析: