Hoj 2995 Area
来源:互联网 发布:思科软件下载 编辑:程序博客网 时间:2024/06/05 21:17
题目:http://acm.hit.edu.cn/hoj/problem/view?id=2995
本题主要是理解题意和理解二分法的思路。
具体还需要学会求简单的定积分。
关于x ≥ 1, y ≥ 1, x * y ≤ C。
代码:
#include <iostream>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <math.h>#include <algorithm>#include <stack>#include <queue>#include <map>using namespace std;//计算x ≥ 1, y ≥ 1, x * y ≤ c时S内有多少个整数点int count(int c){ int ans = 0; for(int i=1;i<=c;i++) { ans += c/i; } return ans;}//二分法求lower_boundint calc(int n){ int low = 1; int high = n; int pos = 1; while(low < high) { int mid = (low + high)/2; if(count(mid)<n) { low = mid + 1; pos = low; } else { high = mid; pos = mid; } } return pos;}int main(){#ifndef ONLINE_JUDGE freopen("in.txt","r",stdin);#endif int t; int n; int c; scanf(" %d",&t); for(int i=0;i<t;i++) { scanf(" %d",&n); if(n == 0) { printf("0.0000\n"); continue; } c = calc(n); printf("%.4lf\n",c*log(c) - (c - 1)); } return 0;}
- Hoj 2995 Area
- Hoj 1143 Area
- HOJ
- (概念题)线段树 HOJ 1495 Area of Simple Polygons
- HOJ 12884 Area Coverage(线段树、求矩形面积并)
- Area
- Area
- Area
- area
- Area
- Area
- HOJ 1004
- 位图-hoj
- HOJ 1020
- HOJ Megaminx
- hoj WERTYU
- hoj 12033
- HOJ-2277
- 前端面试题目
- 64位汇编
- c#中的命名空间
- 计算机网络
- precreatewindow
- Hoj 2995 Area
- ipcs清理命令整理
- Android自定义发送短信实例
- 新浪微博Rsa2加密方式,登录
- Main方法
- [题解]ACMer 2013 Daily Training- 1st Mar for 11x&&12x
- php 验证码步骤和代码
- 项目2:日期结构体
- Structs2拦截器详解