codeforces818F Level Generation -- 三分
来源:互联网 发布:2016网络原创歌曲比赛 编辑:程序博客网 时间:2024/06/05 03:46
可以发现在
那么答案就是
注意到
所以存在
那么在
用三分就可以求出答案。
代码:
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;#define ll long longint i,j,k,n,m,p,Q;double Ans,l,r,m1,m2;inline double Min(double x,double y){ return x<y?x:y;}inline double Max(double x,double y){ return x<y?y:x;}inline double F(double x){ return n-x+Min(x*(x-1)/2,n-x);}int main(){ scanf("%d",&Q); while(Q--){ scanf("%d",&n); l=1;r=n; while(r-l>0.1){ m1=(r-l)/3;m2=r-m1;m1+=l; if(F(m1)>F(m2))r=m2;else l=m1; } l=(int)((l+r)/2); printf("%.0lf\n",Max(F(l),F(l+1))); } return 0;}
阅读全文
0 0
- codeforces818F Level Generation -- 三分
- Codeforces 818F Level Generation(三分)
- Automated Level of Detail Generation for Halo:Reach
- Pat(Advanced Level)Practice--1094(The Largest Generation)
- PAT (Advanced Level) Practise 1094 The Largest Generation (25)
- PAT (Advanced Level) Practise 1094 The Largest Generation (25)
- 【PAT】【Advanced Level】1094. The Largest Generation (25)
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- 三分
- apk签名详解
- 需求文档
- Quadstone Paramics 6.4.1 交通仿真
- Scrapy爬取图片并保存
- RCF的优势--分布式应用
- codeforces818F Level Generation -- 三分
- Python学习系列:高级特性
- Service及AIDL
- 三:win7 下hadoop,eclipse开发环境配置
- Java集合系列之LinkedList源码分析
- 树上平均值
- JSP_C
- express-4-路由
- 我的Java开发学习之旅------>在Dos环境下Java内部类的编译和运行