HDU 1597 find the nth digit (二分查找)
二分查找
1 #include<stdio.h> 2 __int64 a[65555]; 3 void init() 4 { 5 a[0]=0; 6 for(int i=1;i<65537;i++) 7 { 8 a[i]=a[i-1]+i; 9 } 10 } 11 int search(int n,int low,int high) 12 { 13 int temp=(low+high)/2; 14 if(n==a[temp]) return temp-1; 15 if(low>=temp) return temp; 16 if(n>a[temp]) return search(n,temp,high); 17 if(n<a[temp]) return search(n,low,temp); 18 } 19 int main() 20 { 21 int k,flag,n; 22 init(); 23 scanf("%d",&k); 24 while(k--) 25 { 26 scanf("%d",&n); 27 int temp=search(n,1,65536); 28 n-=a[temp]; 29 n%=9; 30 if(n) printf("%d\n",n); 31 else printf("9\n"); 32 } 33 }
转载于:https://www.cnblogs.com/lqquan/p/3730601.html
HDU 1597 find the nth digit (二分查找)相关推荐
- hdu 1597 find the nth digit(等差求和+二分)
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- HDU - 1597 find the nth digit 【找规律】
Description 假设: S1 = 1 S2 = 12 S3 = 123 S4 = 1234 ......... S9 = 123456789 S10 = 1234567891 S11 = 12 ...
- 杭电1597 find the nth digit
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- 【HDOJ】1597 find the nth digit
二分. 1 #include <stdio.h> 2 #include <math.h> 3 4 int main() { 5 int case_n; 6 double n, ...
- hdu1597 find the nth digit(二分查找)
find the nth digit Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Other ...
- hdu 1597 二分查找
题目很容易理解,给定一个字符串,是有1-9字符组成,在里面1就是1:2就是12:3就是123:10就是1234567891.依次连接. 给定一个位数需要去确定这个位数上的数到底是几? 本题看似一个字符 ...
- hdu 4004 二分查找
直接二分查找答案即可,我的判断函数没有像大牛们那样优化,但是过是没问题的~ /* * hdu4004/linux.cpp * Created on: 2011-9-4 * Author : ben*/ ...
- hdu 2141 Can you find it? hdu1597 find the nth digit
hdu2141 唉,是我 想多了,用普通方法拼命剪枝,还是TLE 直接将前俩个数组的和求出来并保存,之后就是一个二分查找的过程了 二分的俩种写法 第一种 #include<iostream> ...
- 算法前戏 递归 二分查找 列表查找
一.递归 概念: 函数直接或者间接的调用自身算法的过程,则该函数称为递归函数.在计算机编写程序中,递归算法对解决一大类问题是十分有效的. 特点: ①递归就是在过程或者函数里调用自身. ②在使用递归策略 ...
最新文章
- 到了管理层我才发现,这些管理知识应该尽早学起来!
- 地铁线路辅助绘图设计---不做简单的画图师
- 半波对称振子方向图_移动天线的概念 | 天线方向性
- 使用Github(创建仓库、仓库主页说明)
- kafka topic 目录存放在哪_Kafka系列文章之安装测试-第2篇
- Keras:Transfer learning
- 哥德巴赫猜想(升级版)(洛谷-P1579)
- Three20 NetWork
- 【数据结构笔记23】C实现:表示图的多种方法(邻接矩阵、邻接表与相关拓展)
- c++ floor 赋值_C++之floor函数
- LNMP架构数据迁移到NFS存储
- 替换Word文档里面的多个空格
- python爬虫之批量下载小说
- python正则表达式抽取mysql慢查询sql本身,de-parameterize,将参数值改为?
- 超详细教程:YOLO_V3(yolov3)训练自己的数据
- Unsupported class file major version 55
- 关于 SQL Server Reporting Services 匿名登录的解决方案
- 绘制管理组织结构图方法介绍
- 计算机刻录机无法显示,电脑不识别刻录机是为什么
- Python+医学院校二手书管理 毕业设计-附源码201704
热门文章
- activiti高亮显示图片_如今透明LED显示屏成为广告橱窗,它们之间有什么关联?...
- C语言和指针的本质是什么?技术大神给出答案
- linux uboot 源码分析,UBoot源码分析1.pdf
- mathtype运行时错误48_在office中无法使用MathType该怎么办?
- android studio on/off 切换开关,如何使用android studio中的开关小部件来启用/禁用函数()?...
- python odoo_Odoo开发教程20-使用 Python 虚拟环境安装 Odoo第二讲
- 为什么python代码运行不了_为什么Python代码能运行但是PyCharm给我画红线?
- 牛客网数据开发题库_数据库刷题—牛客网(21-30)
- 子进程 已安装 post-installation 脚本 返回错误状态 1 dpkg: 依赖关系问题使得 mysql-server 的配置工作不能继续: mysql-server 依赖于 mysq
- 【渝粤教育】电大中专电商运营实操 (23)作业 题库