题目描述

Small koala special love LiaoHan (of course is very handsome boys), one day she saw N (N<1e18) guys standing in a row, because the boys had some strange character,The first time to Liao them will not be successful, but the second time will be successful; third times to Liao them  will not be successful, but the fourth time will be successful;....... By analogy (toxic psycho)

So the little koala burst odd thought of a fancy up method. The N is the sum of handsome boys, and labeled from 1 to N, starting from the first guy, whose number is 1, she will Liao all the boys whose number is Multiple of 1, then number 2 and all the boys whose number is Multiple of 2(toxic method)

Later, little Kola found that some handsome guys did not get her Liao, she asked the smart you to help her look for how many handsome guys did not successfully be Liaoed?

输入描述:

Multiple groups of Case. (no more than 10000 groups)
Each group of data is 1 lines, with an integer N per line.
The N is 0 at the end of the input.

输出描述:

Each group of Output1 rows, a number of 1 lines representing the number of boys with no Liao to the group of data.
示例1

输入

1
2
3
4
0

输出

1
1
1
2

题解

规律。

暴力打表后会发现有规律,答案就是$\sqrt{n}$,比赛的时候写了个二分...

#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; long long n; bool check(long long x) {
if((2LL + x) * x >= n) return 1;
return 0;
} int main() {
while(~scanf("%lld", &n)) {
if(n == 0) break;
long long L = 1, R = 1e9, ans;
while(L <= R) {
long long mid = (L + R) / 2;
if(check(mid)) ans = mid, R = mid - 1;
else L = mid + 1;
}
printf("%lld\n", ans);
}
return 0;
}

  

湖南大学ACM程序设计新生杯大赛(同步赛)L - Liao Han的更多相关文章

  1. 湖南大学ACM程序设计新生杯大赛(同步赛)J - Piglet treasure hunt Series 2

    题目描述 Once there was a pig, which was very fond of treasure hunting. One day, when it woke up, it fou ...

  2. 湖南大学ACM程序设计新生杯大赛(同步赛)A - Array

    题目描述 Given an array A with length n  a[1],a[2],...,a[n] where a[i] (1<=i<=n) is positive integ ...

  3. 湖南大学ACM程序设计新生杯大赛(同步赛)B - Build

    题目描述 In country  A, some roads are to be built to connect the cities.However, due to limited funds, ...

  4. 湖南大学ACM程序设计新生杯大赛(同步赛)I - Piglet treasure hunt Series 1

    题目描述 Once there was a pig, which was very fond of treasure hunting. The treasure hunt is risky, and ...

  5. 湖南大学ACM程序设计新生杯大赛(同步赛)E - Permutation

    题目描述 A mod-dot product between two arrays with length n produce a new array with length n. If array ...

  6. 湖南大学ACM程序设计新生杯大赛(同步赛)D - Number

    题目描述 We define Shuaishuai-Number as a number which is the sum of a prime square(平方), prime cube(立方), ...

  7. 湖南大学ACM程序设计新生杯大赛(同步赛)H - Yuanyuan Long and His Ballons

    题目描述 Yuanyuan Long is a dragon like this picture?                                     I don’t know, ...

  8. 湖南大学ACM程序设计新生杯大赛(同步赛)G - The heap of socks

    题目描述 BSD is a lazy boy. He doesn't want to wash his socks, but he will have a data structure called ...

  9. 湖南大学ACM程序设计新生杯大赛(同步赛)C - Do you like Banana ?

    题目描述 Two endpoints of two line segments on a plane are given to determine whether the two segments a ...

随机推荐

  1. Spring容器简介

    Spring 是面向 Bean 的编程(BOP,Bean Oriented Programming),提供了 IOC 容器通过配置文件或者注解的方式来管理对象之间的依赖关系. 控制反转模式(也称作依赖 ...

  2. spring boot 使用logback日志系统的详细说明

    springboot按照profile进行打印日志 log4j logback slf4j区别? 首先谈到日志,我们可能听过log4j logback slf4j这三个名词,那么它们之间的关系是怎么样 ...

  3. GridControl详解(七)事件

    private void gridView1_RowCellClick(object sender, DevExpress.XtraGrid.Views.Grid.RowCellClickEventA ...

  4. IO流-LineNumberReader

    LineNumberReader继承自BufferedReader,比其多了两个方法,用于设置和获取当前行号, setLineNumber(); getLineNumber();

  5. linux平台 PHP 实现 word转pdf的艰难历程...

    1.网上搜索资料 无非是 openoffice + PHP的com组件 然而试了很多次 都不可靠 2.后来找到 openoffice + jodconverter(需java环境) 一.安装openo ...

  6. [POJ3370]&[HDU1808]Halloween treats 题解(鸽巢原理)

    [POJ3370]&[HDU1808]Halloween treats Description -Every year there is the same problem at Hallowe ...

  7. Oracle笔记之约束

    约束用于保证数据库中某些数据的完整性,给某一列添加一个约束可以保证不满足约束的数据是绝对不会被接受的. 约束主要有那么五种类型:非空约束.唯一约束.主键约束.外键约束.校验约束. 使用如下命令检索某个 ...

  8. 商城项目(ssm+dubbo+nginx+mysql统合项目)总结(3)

    我不会在这里贴代码和详细步骤什么的,我觉得就算我把它贴出来,你们照着步骤做还是会出很多问题,我推荐你们去看一下黑马的这个视频,我个人感觉很不错,一步一步走下来可以学到很多东西.另外,视频和相关文档的话 ...

  9. B2旅游签证记

    先去https://ceac.state.gov/ceac/,选择DS-160表格,在线申请登记个人信息 ,选择大事馆“CHINA BEIJING”和验证码,点 Start an Applicatio ...

  10. window server 2008 配置ftp并实现用户隔离

    文件传输协议(FTP)是一个标准的网络协议,用于传输计算机文件从一台主机到另一台主机通过TCP为基础的网络,如互联网. -WIKI百科 好久没更新教程了, 今天更新一下博客,也不知道会不会有人看….本 ...