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