H - Treasure Hunt IV

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu

Description

  Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled a from b in front of her.
  Alice was very excited but unfortunately not all of the treasures are real, some are fake.
  Now we know a treasure labled n is real if and only if [n/1] + [n/2] + ... + [n/k] + ... is even.
  Now given 2 integers a and b, your job is to calculate how many real treasures are there.

Input

  The input contains multiple cases, each case contains two integers a and b (0 <= a <= b <= 263-1) seperated by a single space. Proceed to the end of file.

Output

  Output the total number of real treasure.

Sample Input

0 2
0 10

Sample Output

1
6 题意:给你一个Long long范围的区间,然后问里面有多少个数,满足n/1+n/2+n/k……加起来等于一个偶数
题解:首先打表,然后我们发现这种数是扎堆存在的,[0,1),[4,9),[16,25),……
然后我们就这样子找规律,然后一个等差数列求和就好啦!
LL solve(LL n)
{
LL m = (LL)sqrt(n*1.0);
LL sum=;
if(m%==) sum = n-m*m;
if(m%==) m++;
LL j=m/;
sum=sum-j+*j*j;
// sum=sum+2*j*j-j;
return sum;
}
int main()
{
LL n,m;
while(scanf("%llu%llu",&n,&m)>)
{
n++,m++;
LL ans=solve(n-);
LL cur =solve(m);
printf("%llu\n",cur-ans);
}
return ;
}

zoj 3629 Treasure Hunt IV 打表找规律的更多相关文章

  1. ZOJ3629 Treasure Hunt IV(找规律,推公式)

    Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland ...

  2. zoj Treasure Hunt IV

    Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland ...

  3. ZOJ3629 Treasure Hunt IV(找到规律,按公式)

    Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB Alice is exploring the wonderland ...

  4. 【ZOJ】3785 What day is that day? ——浅谈KMP在ACM竞赛中的暴力打表找规律中的应用

    转载请声明出处:http://www.cnblogs.com/kevince/p/3887827.html    ——By Kevince 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这 ...

  5. 【ZOJ】3785 What day is that day? ——KMP 暴力打表找规律

    转自:http://www.cnblogs.com/kevince/p/3887827.html 首先声明一下,这里的规律指的是循环,即找到最小循环周期. 这么一说大家心里肯定有数了吧,“不就是nex ...

  6. hdu 3032 Nim or not Nim? (SG函数博弈+打表找规律)

    Nim or not Nim? Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Sub ...

  7. HDU 5753 Permutation Bo (推导 or 打表找规律)

    Permutation Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5753 Description There are two sequen ...

  8. HDU 4861 Couple doubi (数论 or 打表找规律)

    Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...

  9. HDU2149-Good Luck in CET-4 Everybody!(博弈,打表找规律)

    Good Luck in CET-4 Everybody! Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K ...

随机推荐

  1. 系统架构之负载均衡【F5\nginx\LVS\DNS轮询\】

    在做系统架构规划的时候,负载均衡,HA(高可用性集群,是保证业务连续性的有效解决方案,一般有两个或两个以上的节点,且分为活动节点及备用节点,当活动节点出现故障的时候,由备用节点接管)都是经常需要考虑的 ...

  2. git clone直接提交用户名和密码

    git使用用户名密码clone的方式: git clone http://username:password@remote 例如:我的用户名是abc@qq.com,密码是abc123456,git地址 ...

  3. java基础62 JavaScript中的函数(网页知识)

    1.JavaScript中,函数的格式 function 函数名(形参列表){ 函数体; } 2.JavaScript中,函数需要注意的细节 1.在javaScript中,函数定义形参时,是不能使用v ...

  4. Java 中判断字符串是否为空

    public class TestString { public static void main(String[] args) { String abc = null; //先判断是否为null再判 ...

  5. oralce 笔记

    查某一表的行数 select max(rownum) from tablename 插入数据之前判断是否重复 insert into tablename (coloum1,coloum2) selec ...

  6. nginx学习 一.window下安装

    1. nginx下载路径 http://nginx.org/en/download.html 2.下载后解压到一个没有中文名的文件夹中 3.修改server下location的root为具体的路径,修 ...

  7. nodejs 项目,请求返回Invalid Host header问题

    今天在linux上安装node,使用node做一个web服务器,在linux上安装各种依赖以后开始运行但是,出现了:Invalid Host header 的样式,在浏览器调试中发现是node返回的错 ...

  8. flex布局防止被挤压 flex-shrink: 0

    lex布局非常好用,但在开发过程中可能会碰到的一些坑 1.内容超出容器大致情况是:在一个设置了display:flex布局的大容器A中并排放置两个子容器,并且子容器设置flex:1,子容器中都有一个元 ...

  9. install vscode on centos

    1.down load package from https://code.visualstudio.com/docs/?dv=linux64 2.tar zxf code-stable-code_1 ...

  10. MySQL性能优化之char、varchar、text的区别

    参考来源:https://blog.csdn.net/brycegao321/article/details/78038272 在存储字符串时, 可以使用char.varchar或者text类型, 那 ...