BestCoder Round #84 Dertouzos
2016-07-23 20:52
375 查看
Dertouzos
Accepts: 205Submissions: 1040
Time Limit: 7000/3500 MS (Java/Others)
Memory Limit: 131072/131072 K (Java/Others)
问题描述
正整数$x$称为$n$的positive proper divisor, 当且仅当$x | n$并且$1 \le x < n$. 例如, 1, 2, 和3是6的positive proper divisor, 但是6不是. Peter给你两个正整数$n$和$d$. 他想要知道有多少小于$n$的整数, 满足他们的最大positive proper divisor恰好是$d$.
输入描述
输入包含多组数据, 第一行包含一个整数$T$ $(1 \le T \le 10^6)$表示测试数据组数. 对于每组数据: 第一行包含两个整数$n$和$d$ $(2 \le n, d \le 10^9)$.
输出描述
对于每组数据, 输出一个整数.
输入样例
9 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10 9 100 13
输出样例
1 2 1 0 0 0 0 0 4
在BC上AC的第一道题,题意很好理解,但是暴力解的话,容易超时。
#include<stdio.h> int f(__int64 m) { int i=2; while(m%i!=0) { i++; } return m/i; } //找出一个数的<span style="font-family: Arial, Helvetica, sans-serif;">最大positive proper divisor</span> int main() { int t; __int64 n,d; scanf("%d",&t); while(t--) { __int64 sum=0; scanf("%I64d%I64d",&n,&d); for(__int64 i=2*d;i<n;) //找规律 { if(f(i)==d) sum++; i=i+d; } printf("%I64d\n",sum); } return 0; }
相关文章推荐
- poj 3348 Cows (叉积计算凸包面积)
- Linux 关机/重启/注销命令
- cygwin使用笔记
- Learning Python 012 函数式编程 2 返回函数 匿名函数 装饰器 偏函数
- Learning Python 012 函数式编程 2 返回函数 匿名函数 装饰器 偏函数
- HTML__图片轮播ion-slide-box
- APP项目如何与插件化无缝结合(三)
- jstack和dump内存分析
- 2016 北邮暑期训练3-D题(Codeforces 698A Vacations)DP,水题
- 剑指offer 36题 【时间空间效率的平衡】数组中的逆序对
- 把异常写在日志中
- Java 面向对象 package/import/import static
- PHP CMS的pc标签
- POJ-1328 Radar Installation
- Redis学习笔记五——启动警告问题的解决
- POJ 2406 Power Strings kmp算法求循环节
- Android开发:日期格式化
- 网络爬虫(一)--抓取天气预报网站城市信息
- 智选物流-API接口平台(淘宝菜鸟、快递鸟)
- 5款可以教你编程的游戏