cf Educational Codeforces Round 54 C. Meme Problem
原题:
C. Meme Problem
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
You are given a non-negative integer d. You have to find two non-negative real numbers a and b such that a+b=d and a⋅b=d.
Input
The first line contains t (1≤t≤10^3) — the number of test cases.
Each test case contains one integer d (0≤d≤10^3).
Output
For each test print one line.
If there is an answer for the i-th test, print “Y”, and then the numbers a and b.
If there is no answer for the i-th test, print “N”.
Your answer will be considered correct if ∣(a+b)−a⋅b∣≤10−6|(a+b)−a⋅b|≤10^{−6}∣(a+b)−a⋅b∣≤10−6 and ∣(a+b)−d∣≤10−6|(a+b)−d|≤10^{−6}∣(a+b)−d∣≤10−6.
Example
inputCopy
7
69
0
1
4
5
999
1000
output
Y 67.985071301 1.014928699
Y 0.000000000 0.000000000
N
Y 2.000000000 2.000000000
Y 3.618033989 1.381966011
Y 997.998996990 1.001003010
Y 998.998997995 1.001002005
中文:
给你一个数d,让你找出两个数a和b,使得a+b=d,a×b=d,如果存在这两个数,输出Y然后输出a和b,否则输出N
代码:
#include <bits/stdc++.h>using namespace std;
typedef long long ll;
typedef pair<int,int> pii;int t;
double d,a,b;
int main()
{ios::sync_with_stdio(false);cin>>t;while(t--){cin>>d;if(d*d-4*d<0){cout<<"N"<<endl;continue;}double tmp=sqrt(d*d-4*d);cout<<fixed<<setprecision(9)<<"Y"<<" "<<(d+tmp)/2<<" "<<(d-tmp)/2<<endl;}return 0;
}
解答:
这题也太简单了吧-_-|||
2元一次方程求解的问题,上过初中的应该都能解决
cf Educational Codeforces Round 54 C. Meme Problem相关推荐
- Educational Codeforces Round 54 (Rated for Div.2)
Educational Codeforces Round 54 (Rated for Div.2) D. Edge Deletion 题意:一张n个点的无向图,保留其中k条边,使得有尽可能多的点与1的 ...
- cf Educational Codeforces Round 85 (Rated for Div. 2)B. Middle Class
题目链接:https://codeforces.com/contest/1334/problem/B B. Middle Class time limit per test2 seconds memo ...
- Educational Codeforces Round 54
这套题不难,但是场上数据水,导致有很多叉点 A. 因为是让求删掉一个后字典序最小,那么当a[i]>a[i+1]的时候,删掉a[i]一定最优!这个题有个叉点,当扫完一遍如果没有满足条件的,就删去最 ...
- Educational Codeforces Round 54 (Rated for Div. 2) D Edge Deletion (SPFA + bfs)
题目大意:给定你一个包含n个点m条边的无向图,现在最多在图中保留k条边,问怎么删除多的边,使得图中良好的节点数最多,求出保留在图中的边的数量和编号. 良好的节点定义为:删除某条边后该点到点1的最短距离 ...
- cf Educational Codeforces Round 133 C. Robot in a Hallway
原题: There is a grid, consisting of 2 rows and m columns. The rows are numbered from 1 to 2 from top ...
- CF Educational Codeforces Round 57划水记
因为是unrated于是就叫划水记了,而且本场也就用了1h左右. A.B:划水去了,没做 C:大水题,根据初三课本中圆的知识,可以把角度化成弧长,而这是正多边形,所以又可以化成边数,于是假设读入为a, ...
- Educational Codeforces Round 54 (Rated for Div. 2): D. Edge Deletion(最短路树)
题意: 给你n个点m条边的无向图,其中1号节点是市中心,你现在最多只能保留k条边,并要求所有点到市中心的最短路尽量不变(也就是说设点i到点1的最短路为di,那么删边之后,要保证尽可能多的点,它到1的最 ...
- Educational Codeforces Round 54 (Rated for Div. 2): E. Vasya and a Tree(DFS+差分)
题意: 给你一棵n个节点的树,每个点有一个权值,初始全为0,m次操作,每次三个数(v, d, x)表示只考虑以v为根的子树,将所有与v点距离小于等于d的点权值全部加上x,求所有操作完毕后,所有节点的值 ...
- cf Educational Codeforces Round 49 D. Mouse Hunt
原题: Medicine faculty of Berland State University has just finished their admission campaign. As usua ...
最新文章
- R语言break函数和next函数实战
- 美国五大科技巨头的人工智能竞赛
- 实用精美的导航条制作
- 【NLP】simhash判断文档相似度
- HDU 5115 Dire Wolf 区间dp
- CentOS 初体验十二:wget下载文件
- Linux vi 双屏显示,manjaro AwesomeWM 上使用双显示器
- oracle t44,SecureFiles LOBs基础知识之存储篇
- QML与C++混合编程详解
- git已经删除了远程分支,但本地环境仍能看到远程分支
- Google 不要 Android 了?新系统 Fuchsia 或将支持 Java
- 前端传入JSON数组转换对象存入数据库
- 安卓模拟器安装教程_[教程]安卓手机如何安装百度输入法五笔字根皮肤[教程]...
- linux下nohup后台运行RSSHub等nodejs项目,开启与关闭
- Go strings.ToLower函数
- 2、Class和Subclass
- [渝粤教育] 中国地质大学 人力资源开发与管理 复习题 (2)
- Flutter 仿网易云音乐App
- ShapeAlias
- MFC CFileDialog使用
热门文章
- vue的provide的使用
- JavaSE 实战 中奖判断
- (下)开发一款微信小程序的个性简历,能打开大厂之门并获得门票?(附源码)
- RPA 项目经验分享
- vs2017--MFC读写excel
- 红米4A Android 版本,红米4A评测:4A搭载深度定制基于Android6.0.1系统MIUI 8 - 红米4A评测:双11手机单品销量第一 怎么样好不好用?...
- python随机生成32位乱码,由字母,数字和特殊符号
- Linux哪个压缩命令可以在window上解压的
- 如何安装打印机驱动程序
- 整理英语句子:将首字母大写,单词之间只能一个空格,最后加句号