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. LINUX修改、增加IP的方法,一张网卡绑定多个IP/漂移IP【转】

    临时增加IP命令:ifconfig eth0:1 ip地址 netmask 子网码 broadcast 广播地址 gateway 网关  ifconfig eth0:1 10.1.104.65 net ...

  2. 用jquery的ajax方法获取不到return返回值

    如果jquery中,获取不到ajax返回值. 两个错误写法会导致这种情况:1.ajax未用同步 2.在ajax方法中直接return返回值. 下面列举了三种写法,如果想成功获取到返回值,参考第三种写法 ...

  3. 【转】GridView 加载空行并点击编辑每一个单元格

    代码 <script runat="server"> protectedvoid Button1_Click(object sender, System.EventAr ...

  4. 学习记录:mongodb里插入整型值

    =============================================== 2018/1/24_第1次修改                       ccb_warlock == ...

  5. 从源码分析StringUtils包

    今天用到StringUtils.join方法,闲来无聊,看了下源码 当然不可能自己分析,你傻啊,在这里推荐一个别人分析的; http://blog.csdn.net/baidu_31071595/ar ...

  6. Java I/O系列汇总

    1.Java I/O---概述 2.Java I/O---File类 3.Java I/O---获取文件目录并写入到文本 4.Java I/O---输入与输出 5.Java I/O---复制文本文件 ...

  7. 【Sequel Pro】下载查询结果乱码问题处理方式

    1.下载查询结果已CSV格式保存 2.出现乱码问题样式如下截图: 3. 右键下载的CSV文件,选择用文本编辑打开 4.全选打开的页面内容,重新新建“文本编辑”并进行“储存” 5.打开 1.CSV,则看 ...

  8. Ubuntu 使用命令更新 Ubuntu 系统

    我们都知道 Ubuntu 是一款 Linux 系统,是开源的系统,随时都在更新,所以人们都说 Linux 系统要比 Windows 系统安全.那么为了我们的电脑安全,我们如何利用 Ubuntu 命令来 ...

  9. mongo 运维管理学习

    1 如何在线修改chunk大小 https://docs.mongodb.com/manual/tutorial/modify-chunk-size-in-sharded-cluster/ 2 chu ...

  10. Hadoop案例(十一)MapReduce的API使用

    一学生成绩---增强版 数据信息 computer,huangxiaoming,,,,,,, computer,xuzheng,,,,, computer,huangbo,,,, english,zh ...