HDU 4279 Number(2012天津网络游戏---数论分析题)
2015-08-12 08:55
766 查看
转载请注明出处:http://blog.csdn.net/u012860063?
viewmode=contents
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4279
题意:
给出一个f(x),表示不大于x的正整数里,不整除x且跟x有大于1的公约数的数的个数。
定义F(x),为不大于x的正整数里,满足f(x)的值为奇数的数的个数。题目就是求这个F(x)。
代码例如以下:(用C++提交WA了无数次,用G++一遍过)
viewmode=contents
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4279
HDU集训队选拔赛地点:3教3楼机房,时间:5月10日(周六)12:00開始。请相互转告,谢谢~ 百度之星编程大赛——您报名了吗? |
NumberTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2936 Accepted Submission(s): 805 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 field=problem&key=2012%20ACM/ICPC%20Asia%20Regional%20Tianjin%20Online&source=1&searchmode=source&PHPSESSID=tkomfbjj4pcd0ear72cqdv1pg1" style="color:rgb(26,92,200); text-decoration:none">2012 ACM/ICPC Asia Regional Tianjin Online Recommend liuyiding |
给出一个f(x),表示不大于x的正整数里,不整除x且跟x有大于1的公约数的数的个数。
定义F(x),为不大于x的正整数里,满足f(x)的值为奇数的数的个数。题目就是求这个F(x)。
代码例如以下:(用C++提交WA了无数次,用G++一遍过)
#include<cstdio> #include<cmath> #include<iostream> #include<algorithm> using namespace std; //大于4。并且不是偶数的平方数的偶数是real number //奇数的平方的奇数是real number __int64 calc(__int64 n)//计算小于等于n的real number的个数 { if(n<=4) return 0; __int64 t=sqrt(n*1.0); __int64 ans=(n-4)/2;//大于4的偶数的个数 if(t%2==0) return ans; else return ans+1; } int main() { int T; __int64 A,B; scanf("%d",&T); while(T--) { scanf("%I64d%I64d",&A,&B); printf("%I64d\n",calc(B)-calc(A-1)); } return 0; }
相关文章推荐
- C#网络编程(接收文件) - Part.5
- C#网络编程(订立协议和发送文件) - Part.4
- C#网络编程(同步传输字符串) - part.2
- 学习indy组件之一idhttp的使用方法
- [delphi]indy idhttp post方法
- Qt 网络开发基础
- Windows 2008 R2 2012 R2服务器备份高级应用之---增量备份到网络
- 安卓获取远程值http和saop
- Linux网络编程(附1)——封装read、write
- tcp三次握手的过程,accept发生在三次握手哪个阶段?
- nginx http核心模块指令(二)
- 流媒体高清视频校园直播点播
- yum 安装svn+httpd
- virtualbox 网络设置(桥接、host-ony)模式
- linux中select网络通信
- 黑马程序员——Java基础---GUI,网络编程
- java网络通信编程
- eclipse启动Tomcat服务输入http://localhost:8080/报404解决方法
- nginx中http核心模块的配置指令1
- 如何抓包(获得网络数据)