hdu4279 Number

Number

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2284 Accepted Submission(s): 632


Problem Description
  Here are two numbers A and B (0 < A <= B). If B cannot be divisible by A, and A and B are not co-prime numbers, we define A as a special number of B.
  For each x, f(x) equals to the amount of x’s special numbers.
  For example, f(6)=1, because 6 only have one special number which is 4. And f(12)=3, its special numbers are 8,9,10.
  When f(x) is odd, we consider x as a real number.
  Now given 2 integers x and y, your job is to calculate how many real numbers are between them.

Input
  In the first line there is an integer T (T <= 2000), indicates the number of test cases. Then T line follows, each line contains two integers x and y (1 <= x <= y <= 2^63-1) separated by a single space.

Output
  Output the total number of real numbers.

Sample Input
  
  
2 1 1 1 10

Sample Output
  
  
0 4
Hint
For the second case, the real numbers are 6,8,9,10.

Source

Recommend
liuyiding
暴力打表找规律
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;
__int64 num[15]={0,0,0,0,0,0,1,1,2,3,4,4,5};
__int64 get(__int64 x)
{
    if(x<=12)return num[x];
    __int64 temp=(__int64)sqrt((double)x);
    if(temp&1)
        return x/2-1;
    else
        return x/2-2;

    return -1;
}
int main()
{
    int tcase;
    __int64 m,n;
    scanf("%d",&tcase);
    while(tcase--)
    {
        scanf("%I64d%I64d",&n,&m);
        n--;
        __int64 p1=get(n);
        __int64 p2=get(m);
        printf("%I64d\n",p2-p1);
    }
    return 0;
}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值