题目大意:

Adilbek有一个特殊项目,他需要运行这个项目得到结果。

但是这个项目直接运行需要消耗d天时间。

他也可以选择优化程序以减少程序运行消耗时间。

假设他用了x天优化程序,那么最后运行程序只需要消耗天的时间(括号指向上取整)。

那么总共需要消耗的天数是

问,他能不能在n天内得到结果?

解题思路:

问能不能在n天内得到结果,只需要求出最少需要的天数与n对比即可。

可得到

那么总天数为

当且仅当

时成立。

所以

又因为x必为整数

所以x取上式向下取整后代入公式,再取向下取整+1代入公式,得出的两个结果取小作为答案。

#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio();
cin.tie();cout.tie();
int T,n,d,x,i,j,k;
cin>>T;
while(T--){
cin>>n>>d;
x=sqrt(d-0.75)-0.5;
if(x+(d+x)/(x+)<=n||x++(d+x+)/(x+)<=n)
cout<<"YES\n";
else
cout<<"NO\n";
} return ;
}

Codeforces 1288A - Deadline的更多相关文章

  1. Educational Codeforces Round 80 (Rated for Div. 2)

    A. Deadline 题目链接:https://codeforces.com/contest/1288/problem/A 题意: 给你一个 N 和 D,问是否存在一个 X , 使得 $x+\lce ...

  2. Educational Codeforces Round 80 A-E简要题解

    contest链接:https://codeforces.com/contest/1288 A. Deadline 题意:略 思路:根据题意 x + [d/(x+1)] 需要找到一个x使得上式小于等于 ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. SQL约束攻击

    本文转载自https://blog.csdn.net/kkr3584/article/details/69223010 目前值得高兴的是,开发者在建立网站时,已经开始关注安全问题了--几乎每个开发者都 ...

  2. 吴裕雄--天生自然 PHP开发学习:字符串变量

    <?php $txt="Hello world!"; echo $txt; ?> <?php $txt1="Hello world!"; $t ...

  3. Linux基础(1) 安装

    Linux基础 一.创建CentOS 7 Linux虚拟机 1.安装虚拟机     桥接网络:相当于这台机器就是物理机,多个电脑在连接在一个交换机上,同一个子网 NAT:这台机器只能通过物理机(相当于 ...

  4. Redis: Reducing Memory Usage

    High Level Tips for Redis Most of Stream-Framework's users start out with Redis and eventually move ...

  5. VUE.js入门学习(1)-起步

    1.hello world <div id="app">{{content}}</div>var app = new Vue({ el:'#app', da ...

  6. VUE常见的语法

    模版渲染{{msg}} v-html="" v-text="" v-bind:id=""  类似 attr 三元判断 {{ok?'yes': ...

  7. jquery ajax常用的登录登出

    整理jquery+ajax的登录登出方法. //登录 var currentUserId = -1; $(function() { var timestamp = (new Date()).value ...

  8. Tensorflow学习教程------代价函数

    Tensorflow学习教程------代价函数   二次代价函数(quadratic cost): 其中,C表示代价函数,x表示样本,y表示实际值,a表示输出值,n表示样本的总数.为简单起见,使用一 ...

  9. 18 12 `12 WSGI 协议

    所谓wsig 协议  就是把web框架 和服务器进行分开  然后通过 wisg协议 进行连接  这样子可以随时替换web框架  或者 更换服务器 解耦 (现在学的内容里 静态连接一般是放在服务器里  ...

  10. 云服务器Linux版本下---安装git

    xshell进入云服务器: 按照git官网:https://git-scm.com/download/linux   的教程输入: apt-get install git 本地没有包????? 原来是 ...