CF1076C Meme Problem 数学
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 a⋅b=d
.
The first line contains t
(1≤t≤103
) — the number of test cases.
Each test case contains one integer d
(0≤d≤103)
.
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
and |(a+b)−d|≤10−6
.
7
69
0
1
4
5
999
1000
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
题意:求两个实数 a,b 满足 a+b==d&&a*b==d;
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<ctime>
#include<deque>
#include<stack>
#include<functional>
#include<sstream>
//#include<cctype>
//#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-3
typedef pair<int, int> pii;
#define pi acos(-1.0)
const int N = 1005;
#define REP(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> 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;
}
CF1076C Meme Problem 数学的更多相关文章
- UVa10025 The ? 1 ? 2 ? ... ? n = k problem 数学思维+规律
UVa10025 ? 1 ? 2 ? ... ? n = k problem The problem Given the following formula, one can set operator ...
- POJ 3100 & ZOJ 2818 & HDU 2740 Root of the Problem(数学)
题目链接: POJ:id=3100" style="font-size:18px">http://poj.org/problem? id=3100 ZOJ:http ...
- C. Meme Problem
链接 [http://codeforces.com/contest/1076/problem/C] 题意 a+b=d and a⋅b=d. 计算出a和b 分析 ab=a(d-a)=d aa-ad+d= ...
- UVALive 6909 Kevin's Problem 数学排列组合
Kevin's Problem 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid ...
- hdu 5105 Math Problem(数学)
pid=5105" target="_blank" style="">题目链接:hdu 5105 Math Problem 题目大意:给定a.b ...
- hdu-5858 Hard problem(数学)
题目链接: Hard problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Othe ...
- Codeforces Round #603 (Div. 2) A. Sweet Problem(数学)
链接: https://codeforces.com/contest/1263/problem/A 题意: You have three piles of candies: red, green an ...
- HDU 5105 Math Problem --数学,求导
官方题解: f(x)=|a∗x3+b∗x2+c∗x+d|, 求最大值.令g(x)=a∗x3+b∗x2+c∗x+d,f(x)的最大值即为g(x)的正最大值,或者是负最小值.a!=0时, g′(x)=3∗ ...
- UVa 1640 The Counting Problem (数学,区间计数)
题意:给定两个数m, n,求从 m 到 n 中0-9数字各出现了多少次. 析:看起来挺简单的,其实并不好做,因为有容易想乱了.主要思路应该是这样的,分区间计数,先从个位进行计,一步一步的计算过来.都从 ...
随机推荐
- web基础 (三) CSS
css 层叠样式表 CSS 规则由两个主要的部分构成:选择器,以及一条或多条声明. selector { property: value; property: value; ... property: ...
- 开发环境入门 linux基础 (部分) 复制 用户和组操作 权限更改
复制 用户和组操作 权限更改 CP 复制命令 cp 源文件 目标文件 a) –r(recursive,递归的):递归地复制目录.当复制一个目录时,复制该目录中所有的内容,其中包括子目录的全部内容. b ...
- paramiko监控 windows服务器 被监控服务器只需要安装openssh服务即可基于wmic完成大部分监控
#!/usr/bin/python #-*- coding: UTF-8 -*- #++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ ...
- mybaits中date类型显示时分秒(orcle数据库)
<insert id="insert" parameterType="daSysLoginLog"> insert into DA_SYS_LOGI ...
- 浅谈时钟的生成(js手写代码)(非原创)
在生成时钟的过程中自己想到布置表盘的写法由这么几种: 当然利用那种模式都可以实现,所以我们要用一个最好理解,代码有相对简便的方法实现 1.利用三角函数 用js在三角函数布置表盘的过程中有遇见到这种情况 ...
- html乱码原因与网页乱码解决方法
造成html网页乱码原因主要是html源代码内中文字内容与html编码不同造成.但无论是哪种情况造成乱码在网页开始时候都需要设置网页编码. charset编码设置 html网页乱码效果截图 一.乱码造 ...
- JVM实用参数(一)JVM类型以及编译器模式
JVM实用参数(一)JVM类型以及编译器模式 原文地址:https://blog.codecentric.de/en/2012/07/useful-jvm-flags-part-1-jvm-types ...
- nodejs安装配置
1.安装node.js(6.3.0)2.检测PATH环境变量是否配置了Node.jscmd下node --version3.D:/www/nodejs文件夹下创建hello.jsvar http = ...
- winform 对话框控件
ColorDialog 可以调节颜色的控件,如果给一个按钮点击事件 ColorDialog.showdialog();就会弹出这个 返回值是个枚举类 然后定义一个这个类的变量 接收一下它的返回值 Di ...
- iOS 本地加载js文件
#import "RootViewController.h" @interface RootViewController ()<UIWebViewDelegate> @ ...