时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 32768K,其他语言65536K
64bit IO Format: %lld
题目描述
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

分析:打表找个规律。

#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<algorithm>
#define ll long long int
using namespace std;
const ll maxn = 1e18;
const ll m = 2e9+10;
//void init() {//  ll tmp = 3; int i;
//  ll ans = 0;
//  for (i = 1;; i++) {//      if (ans > maxn) break;
//      ans += tmp;
//      a[i] = ans;
//      tmp += 2;
//  }
//  len = i-1;
//}
ll judge(ll x) {return x*(3 + x * 2 + 1)/2;
}
int main() {ll n;while (scanf("%lld", &n) && n) {int L = 1, R = m ,mid;while (L < R) {mid = (L + R) / 2;if (judge(mid)>= n) {R = mid;}else {L = mid + 1;}}printf("%d\n", L);}return 0;
}

湖南大学ACM程序设计新生杯大赛(同步赛)L-Liao Han【打表规律+二分】相关推荐

  1. 湖南大学第十四届ACM程序设计新生杯(重现赛)- FFind the AFei Numbers(数位dp)

    题目链接 题目描述 AFei loves numbers. He defines the natural number containing "520" as the AFei n ...

  2. 湖南大学第十四届ACM程序设计新生杯(重现赛)L-The Digits String (矩阵快速幂)

    题目链接 题目描述 Consider digits strings with length n, how many different strings have the sum of digits a ...

  3. 第八届“图灵杯”NEUQ—ACM程序设计竞赛个人赛(同步赛)

    A题--切蛋糕 龙龙有一块蛋糕,现在他想将蛋糕平均切成k块,分给他的k名hxd.但是不幸的是,因为龙龙不擅长切蛋糕,他每一次只能将一块蛋糕平均分成两份.例如,将一块大小为1的蛋糕分割成两块大小为1/2 ...

  4. 师创杯”山东理工大学第九届ACM程序设计竞赛(网络同步赛)--I皮卡丘的梦想2

    作为水题王者前去水了一波山东理工大学的校赛,这道题一个小细节坑了我2个小时,思路其实很简单,就是线段树单点更新的模板,用一个60的数组标记,如果这个区间内有I种类的化石,那么就是1,否则为0,加入新化 ...

  5. 2021暨南大学轩辕杯ACM程序设计新生赛题解

    title : 2021暨南大学轩辕杯ACM程序设计新生赛 date : 2021-12-12 tags : ACM,练习记录 author : Linno 题目链接:https://ac.nowco ...

  6. 第八届“图灵杯”NEUQ-ACM程序设计竞赛个人赛(同步赛) 2021.1.30

    第八届"图灵杯"NEUQ-ACM程序设计竞赛个人赛(同步赛) B小宝的幸运数组 C上进的凡凡 D Seek the Joker I E Seek the Joker II H 数羊 ...

  7. 第八届“图灵杯”NEUQ-ACM程序设计竞赛个人赛(同步赛)解题报告

    第八届"图灵杯"NEUQ-ACM程序设计竞赛个人赛(同步赛) 题目总结 A题 切蛋糕 题目信息 解题思路 如果我们将 1/k展开到二进制的形式,那么就可以计算出 需要 多少块1/( ...

  8. 第十二届蓝桥杯大赛软件赛省赛 Python 大学 A 组 试题

    第十二届蓝桥杯大赛软件赛省赛 Python 大学 A 组 试题   大家好,我叫亓官劼(qí guān jié ),在GitHub & CSDN中记录学习的点滴历程,时光荏苒,未来可期,加油~ ...

  9. 蓝桥杯大赛软件赛省赛,C/C++大学B组,改革后2019-2021真题知识点分类

    1.蓝桥杯 比赛时长: 四个小时 比赛规则: 蓝桥杯比赛跟天梯赛.ACM还不太一样,比赛中提交的答案并没有反馈机制,也就是说你提交了答案以后,自己并不知道是对是错,就像考试一样,只有交了卷,成绩下来以 ...

  10. 第十三届蓝桥杯大赛软件赛省赛真题

    第十三届蓝桥杯大赛软件赛省赛Java 大学 B 组 文章目录 第十三届蓝桥杯大赛软件赛省赛Java 大学 B 组 [考生须知] 试题 A: 星期计算 试题 B: 山 试题 C: 字符统计 试题 D: ...

最新文章

  1. gitlab中文_ASP.NET实战010:Visual Studio使用GitLab详解
  2. 每日一皮:为什么程序猿是最适合谈恋爱的人
  3. 字符串从右截取_跟运维组学Python基础day04(字符串str的索引和切片)
  4. Java应用CPU问题排查
  5. 【glibc源码分析】--strcpy.c 字符串复制
  6. 350个特性看透ES6
  7. java如何实现动态时钟_java中的动态时钟
  8. OpenGL ES Emulator再次横向比较
  9. linux startx无法启动
  10. Weka开发[11]—J48源代码介绍
  11. 使用 Nginx 编译 Sass 和 Scss
  12. xcode4 引入poco库
  13. 解决sns.load_dataset()加载失败问题github下载缓慢问题
  14. 迷茫时的3个选择,决定了你人生的高度
  15. 如何更改计算机用户账户和密码,怎么修改电脑用户账户
  16. PCA(主成分分析)获取BoundingBox代码分析
  17. Spring Data JDBC自动生成的增删改查CRUD分页、排序SQL语句非常简洁没有多余的SQL
  18. 组播地址MAC的计算
  19. 如何安装成英文版本的vmware
  20. 电气器件系列二十五:电子式压力传感器PPG-D(2)

热门文章

  1. 从5.56*45mm NATO弹看塔科夫的数据严谨性
  2. 王者勋章服务器维护中,【维护】4月1日官方维护公告(抢鲜服)
  3. 千峰JAVA逆战班Day34
  4. 第四届IT 2020高端论坛成功举办
  5. TCP全连接端口扫描器
  6. 使用.png格式图片,制作.icns格式图片
  7. 纯C语言编程实现数独解法
  8. wps2016向程序发送命令_老司机帮您向程序发送命令时出现错误 【操作步骤】 的设置办法...
  9. Web前端满屋花案例框架
  10. java 游戏背景mp3音乐_java飞机大战(带背景音乐) 游戏原码下载