题目描述

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. 前端PHP入门-014-参数的引用

    我们学习了变量的引用,我们来回顾一下知识: <?php $a = 10; $b = &$a; $a = 100; echo $a.'---------'.$b; ?> 而函数的参数 ...

  2. swift开发常用代码片段

    // 绑定事件 cell.privacySwitch.addTarget(self, action: #selector(RSMeSettingPrivacyViewController.switch ...

  3. 在服务器上运行Jar包

    在服务器上运行Jar包 并且该Jar包依赖其他的Jar文件的时候,采用如下格式 java -Djava.ext.dirs=你依赖的Jar文件路径 -jar 你要运行的Jar文件 包名+类名 例如: j ...

  4. cmd窗口关闭 -----window小技巧!

    前沿 平时开发的时候经常用到windows  的命令行工具来启动程序  或是 查看本地数据库的信息 : 经常的手动关闭 ,对于我这种,能用键盘完成的就坚决不用鼠标的人是多么痛苦. 所以在此罗列了一些命 ...

  5. Redis实战(五)CentOS 7上搭建Redis集群

    高可用Redis(十二):Redis Cluster https://www.cnblogs.com/renpingsheng/p/9862485.html https://www.cnblogs.c ...

  6. 【BZOJ】2301: [HAOI2011]Problem b

    [题意]于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数.n,a,b,c,d,k<=50000. ...

  7. XMLHttpRequest 整理

    看了SF 上的一篇文章感触颇深:你真的会使用XMLHttpRequest吗? 在这我写上我读后的笔记: <!DOCTYPE html> <html lang="en&quo ...

  8. notepad++突然崩溃,保存的文件没了怎么办

    在C:\Users\你当前用户的用户名\AppData\Roaming\Notepad++\backup  有备份

  9. Bootstrap文件上传组件:bootstrap fileinput

    为了上传预览pdf与图片特用此插件. 源码以及API地址: bootstrap-fileinput源码:https://github.com/kartik-v/bootstrap-fileinput ...

  10. flask插件系列之SQLAlchemy基础使用

    sqlalchemy是一个操作关系型数据库的ORM工具.下面研究一下单独使用和其在flask框架中的使用方法. 直接使用sqlalchemy操作数据库 安装sqlalchemy pip install ...