ZOJ 3629(找规律)

Treasure Hunt IV


Time Limit: 2 Seconds      Memory Limit: 65536 KB



Alice is exploring the wonderland, suddenly she fell into a hole, when she woke up, she found there are b - a + 1 treasures labled afrom 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

额,找规律的题。看见 (0 <= a <= b <=
263-1) 时,就知道暴力会超时了,所以就找规律吧!

先写一个暴力的程序打表,这样的事以前也做过,一个循环节为197的规律题,打表只到100,还以为够了,结果那题没找到规律,以后再做这样的事的时候,先打表到10000再详谈!

#include<stdio.h>
int main()
{
    freopen("呵呵.txt","w",stdout);
    int i;
    for (i=0; i<=1000; i++)
    {
        int ans=0;
        for (int j=1; j<=i; j++)
        {
            ans+=i/j;
        }
        if (ans%2==0)
            printf("%d\t",i);
    }
    return 0;
}

[0^2,1^2)                   1

[2^2,3^2)                   5

[4^2,5^2)                   9

[6^2,7^2)                  13

[8^2,9^2)                  17

[10^2,11^2)              21

[12^2,13^2)              25

. . . .

. . . . . .

ZOJ 3629(找规律),布布扣,bubuko.com

时间: 2024-12-28 00:15:48

ZOJ 3629(找规律)的相关文章

zoj 3629 Treasure Hunt IV(找规律)

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 fromb in front of her.Alice was very excited but unfortunately not all of the treasures are real, some are fake.Now w

zoj 3629 Treasure Hunt IV 打表找规律

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

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

首先声明一下,这里的规律指的是循环,即找到最小循环周期.这么一说大家心里肯定有数了吧,“不就是next数组性质的应用嘛”. 先来看一道题 ZOJ 3785 What day is that day? Time Limit: 2 Seconds      Memory Limit: 65536 KB It's Saturday today, what day is it after 11 + 22 + 33 + ... + NN days? Input There are multiple tes

ZOJ 3622 Magic Number 打表找规律

A - Magic Number Time Limit:2000MS     Memory Limit:32768KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3622 Appoint description: Description A positive number y is called magic number if for every positive integer x it satisfies that

ZOJ 3768Continuous Login(找规律然后二分)

Continuous Login Time Limit: 2 Seconds      Memory Limit: 131072 KB      Special Judge Pierre is recently obsessed with an online game. To encourage users to log in, this game will give users a continuous login reward. The mechanism of continuous log

ZOJ 2686 Cycle Game(博弈 找规律)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1686 Here is a game played on a cycle by two players. The rule of this game is as follows: At first, a cycle is given and each edge is assigned a non-negative integer. Among those intege

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

Treasure Hunt IV Time Limit: 2 Seconds      Memory Limit: 65536 KB 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

Calendar Game(找规律+博弈)

A - Calendar Game Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 1024 Appoint description:  System Crawler  (2015-08-02) Description Adam and Eve enter this year's ACM International Collegiate Pr

The Cow Lineup_找规律

Description Farmer John's N cows (1 <= N <= 100,000) are lined up in a row.Each cow is labeled with a number in the range 1...K (1 <= K <=10,000) identifying her breed. For example, a line of 14 cows might have these breeds: 1 5 3 2 5 1 3 4 4