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 ...
随机推荐
- 关于web中的路径
做了许多Demo发现,浏览器解析的路径和服务器解析的路径是不同的.我们知道,路径加上/的时候,表示的是绝对路径的意思,而如果是服务器解析的话,这个/相对的是我们的web应用,即相对于http://19 ...
- json数组某个数值对应渲染
当你统计某一年的某个值它对应的月份总数时,后台没有直接处理好,某个月对应某个值,这样会增加统计的负担,但当数据时这样的时候,在angularjs中时不能直接引用的. "data": ...
- BZOJ1132: [POI2008]Tro(叉积 排序)
题意 世上最良心题目描述qwq 平面上有N个点. 求出所有以这N个点为顶点的三角形的面积和 N<=3000 Sol 直接模拟是$n^3$的. 考虑先枚举一个$i$,那么我们要算的就是$\sum_ ...
- echarts简单用法快速上手
1.html结构 简单说就是一个标签一个图表:2.初始化:var myEcharts = echarts.init(document.getElementById("xxx")): ...
- 自定义Jquery 下拉框
(function ($){ 'use strict'; var g_id = 0; var g_open_id = []; $.fn.select3 = function () { var _id ...
- Android(java)学习笔记160:开发一个多界面的应用程序之清单文件
清单文件的重要参数: <intent-filter> 代表的应用程序的入口界面 <action android:name=&quo ...
- python小随笔
关于pip安装 .\pip.exe install --ignore-installed --upgrade tensorflow-gpu python可视化库 Seaborn:是一个基于matplo ...
- 爬虫学习之csv读取和存储
一.读取 该读取主要使用到csv里面的Reader().DictReader()方法,和引用io里面的StringIO进行对字符串进行封装 在处理网上的csv文件方式主要是有一下几方面: • 手动把C ...
- java缓存的使用
缓存1,缓存的定义与作用2,缓存的使用范围(命中率高.高访问量)3,缓存策略(命中率,最大元素,清空策略);4,缓存介质(内存缓存,硬盘缓存,数据库缓存)(本地缓存(ehcache,oscache)与 ...
- ios之AFN
https://github.com/AFNetworking/AFNetworking 与asi-http-request功能类似的网络库,不过是基于NSURLConnection 和 NSOper ...