博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CF1076C Meme Problem 数学
阅读量:6701 次
发布时间:2019-06-25

本文共 2607 字,大约阅读时间需要 8 分钟。

Try guessing the statement from this picture:

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 ab=d

.

Input

The first line contains t

(1t103

) — the number of test cases.

Each test case contains one integer d

(0d103)

.

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)ab|106

and |(a+b)d|106

.

Example
Input
Copy
76901459991000
Output
Copy
Y 67.985071301 1.014928699Y 0.000000000 0.000000000NY 2.000000000 2.000000000Y 3.618033989 1.381966011Y 997.998996990 1.001003010Y 998.998997995 1.001002005 题意:求两个实数 a,b 满足 a+b==d&&a*b==d;
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
//#include
//#pragma GCC optimize("O3")using namespace std;#define maxn 400005#define inf 0x3f3f3f3f#define INF 9999999999#define rdint(x) scanf("%d",&x)#define rdllt(x) scanf("%lld",&x)#define rdult(x) scanf("%lu",&x)#define rdlf(x) scanf("%lf",&x)#define rdstr(x) scanf("%s",x)typedef long long ll;typedef unsigned long long ull;typedef unsigned int U;#define ms(x) memset((x),0,sizeof(x))const long long int mod = 1e9 + 7;#define Mod 1000000000#define sq(x) (x)*(x)#define eps 1e-3typedef pair
pii;#define pi acos(-1.0)const int N = 1005;#define REP(i,n) for(int i=0;i<(n);i++)typedef pair
pii;inline ll rd() { ll x = 0; char c = getchar(); bool f = false; while (!isdigit(c)) { if (c == '-') f = true; c = getchar(); } while (isdigit(c)) { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return f ? -x : x;}ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b);}ll sqr(ll x) { return x * x; }/*ll ans;ll exgcd(ll a, ll b, ll &x, ll &y) { if (!b) { x = 1; y = 0; return a; } ans = exgcd(b, a%b, x, y); ll t = x; x = y; y = t - a / b * y; return ans;}*/ll qpow(ll a, ll b, ll c) { ll ans = 1; a = a % c; while (b) { if (b % 2)ans = ans * a%c; b /= 2; a = a * a%c; } return ans;}int T;int d;int main(){ //ios::sync_with_stdio(0); rdint(T); while (T--) { rdint(d); if (d*d < 4 * d)cout << "N" << endl; else { double a = 1.0*(d + sqrt(d*d - 4 * d)) / (2.0); double b = 1.0*d - a; cout << "Y" << ' '; printf("%.9lf %.9lf\n", 1.0*a, 1.0*b); } } return 0;}

 

 

转载于:https://www.cnblogs.com/zxyqzy/p/9961704.html

你可能感兴趣的文章
课堂作业整理三 (集合:list接口)
查看>>
iPhone iPad 各种控件默认高度
查看>>
Android 第一篇
查看>>
1609: [Usaco2008 Feb]Eating Together麻烦的聚餐
查看>>
1477: 青蛙的约会
查看>>
百度Ueditor编辑器wordimage踩坑
查看>>
Volatile的应用
查看>>
leetcode-49-字母异位词分组(神奇的哈希)
查看>>
JavaScript知识概要
查看>>
阿里云服务器一分价钱一分货,切记!
查看>>
Java8函数式编程
查看>>
NOIP 货车运输
查看>>
.NET混淆器 Dotfuscator如何保护应用程序?控制流了解一下!
查看>>
前端知识体系收藏
查看>>
Eclipse开发Android程序如何在手机上运行
查看>>
阿里云对象存储OSS与文件存储NAS的区别
查看>>
[转]CNN目标检测(一):Faster RCNN详解
查看>>
Android 设备的CPU类型(通常称为”ABIs”)
查看>>
Java异常处理001:Maven clean package时Failed to clean project: Failed to delete
查看>>
21OGNL与ValueStack(VS)-静态方法访问
查看>>