Number HDU
来源:互联网 发布:华为5a切换数据流量 编辑:程序博客网 时间:2024/06/18 04:04
Number HDU - 4279
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.
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>using namespace std;int main(){ int t; scanf("%d",&t); while(t--){ long long int n,m,x1,x2;; scanf("%lld%lld",&n,&m); long long int tt=n-1; if (tt==0||tt==1){ x1=0; } else{ long double qq=tt; long long int ss=sqrt(qq); if (ss%2==0){ x1=(n-1)/2-2; } else{ x1=(n-1)/2-1; } } if (m==0||m==1){ x2=0; } else{ long double qq=m; long long int sss=sqrt(qq); if (sss%2==0){ x2=m/2-2; } else{ x2=m/2-1; } } printf("%lld\n",x2-x1); } return 0;}
- number number number HDU
- hdu 6198 number number number
- hdu 6198 number number number
- HDU 6189 number number number
- hdu-6198number number number
- hdu 6198 number number number
- Number HDU
- Number HDU
- HDU 6198 number number number 题解
- hdu 1711 Number Sequence
- hdu 1711 Number Sequence
- HDU 1005 Number Sequence
- HDU 3443 Shift Number
- hdu 1018 Big Number
- HDU 1018 Big Number
- hdu 1711 Number Sequence
- HDU 3880 luck number
- HDU 3709 Balanced Number
- iOS
- 【入门篇】logstash、elasticsearch、kibana搭建日志平台
- CUDA Samples: heat conduction(模拟热传导)
- ffmpeg网址
- 关于ubuntu下HDF5库的安装和问题(HDF5 library version mismatched error)
- Number HDU
- 【代码笔记】iOS-json文件的使用
- 多态
- Android使用线程的方法
- Git for Windows的使用
- 《第一行代码》自学笔记-通过广播接收器监听网络变化
- 李宏毅机器学习课程6~~~深度学习入门
- 信源编码作业六
- 批量添加