The regularity of Zoj 3629 treasure Hunt IV playing table

Source: Internet
Author: User

h-treasure Hunt IV

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

Description

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

Input

The input contains multiple cases, each case contains the 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 20 10

Sample Output

16

Test instructions: Give you a long long range of intervals, and then ask how many numbers inside, meet n/1+n/2+n/k ... Add up equals an even number
The problem: first hit the table, and then we find that this number is found together, [0,1], [4,9), [16,25],......
Then we look for the law, and then a arithmetic progression sum it up!

ll Solve (ll N) {ll m= (LL) sqrt (n1.0); LL sum=0; if(m%2==0) sum = n-m*m; if(m%2==1) m++; LL J=m/2; Sum=sum-j+2*j*J; //sum=sum+2*j*j-j;    returnsum;}intMain () {LL n,m;  while(SCANF ("%llu%llu", &n,&m) >0) {n++,m++; LL ans=solve (n1); LL cur=solve (m); printf ("%llu\n", cur-ans); }    return 0;}

The regularity of Zoj 3629 treasure Hunt IV playing table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.