hdu 2588(简单的欧拉
题意:给你一个n,m问你1-n里面(x)有多少对gcd(x, n)>=m。
思路:我们可以设n=a*b, x=a*c,此时我们可以知道b,c是互质的,那么就可以用欧拉来求解
/* gyt
Live up to every day */
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<cstring>
#include<queue>
#include<set>
#include<string>
#include<map>
#include <time.h>
#define PI acos(-1)
using namespace std;
typedef long long ll;
typedef double db;
const int maxn = 1e6+;
const ll maxm = 1e7;
const ll mod = 1e9 + ;
const int INF = 0x3f3f3f;
const ll inf = 1e15 + ;
const db eps = 1e-;
const int kind=; ll euler(ll n){
ll res=n,a=n;
for(ll i=;i*i<=a;i++){
if(a%i==){
res=res/i*(i-);
while(a%i==) a/=i;
}
}
if(a>) res=res/a*(a-);
return res;
}
void solve() {
ll n, m; scanf("%lld%lld", &n, &m);
ll ans=;
for (ll i=; i*i<=n; i++) {
if (n%i==) {
if (i>=m) ans+=euler(n/i);
if (n/i>=m&&i*i!=n) ans+=euler(i);
}
}
cout<<ans<<endl;
}
int main() {
int t = ;
// freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
scanf("%d", &t);
while(t--)
solve();
return ;
}
hdu 2588(简单的欧拉的更多相关文章
- 题解报告:hdu 2588 GCD(欧拉函数)
Description The greatest common divisor GCD(a,b) of two positive integers a and b,sometimes written ...
- HDU 2588 GCD(欧拉函数)
GCD Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- hdu GuGuFishtion 6390 数论 欧拉函数
题目:http://acm.hdu.edu.cn/showproblem.php?pid=6390 直接开始证明: 我们设…………………………………….....…...............………… ...
- HDU 1695 GCD (欧拉函数+容斥原理)
GCD Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...
- HDU 5430 Reflect(欧拉函数)
题目: http://acm.hdu.edu.cn/showproblem.php?pid=5430 从镜面材质的圆上一点发出一道光线反射NNN次后首次回到起点. 问本质不同的发射的方案数. 输入描述 ...
- hdu 5279 Reflect phi 欧拉函数
Reflect Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://bestcoder.hdu.edu.cn/contests/contest_chi ...
- HDU 1695 GCD(欧拉函数+容斥原理)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1695 题意:x位于区间[a, b],y位于区间[c, d],求满足GCD(x, y) = k的(x, ...
- hdu 1695 GCD (欧拉函数、容斥原理)
GCD Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submis ...
- HDU 1787 GCD Again(欧拉函数,水题)
GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
随机推荐
- dedecms list 添加自定义字段方法
在内容模型管理中,添加字段时需这样:
- php中in_array一些问题
var_dump(in_array(1,['s','1fsdf',12])); // true var_dump(in_array(0,[4,'erdd'])); // true 因为是要用值与数组 ...
- 搭建harbor仓库、LDAP认证
ldap: 192.168.199.177 c5game.com 宿主机:192.168.199.224 测试客户机:192.168.199.223 安装docker.docker-compose 访 ...
- zabbix监测公网IP的客户端主机
未经测试 如果server端是内网的主机,需要注意:防火墙.端口映射 再用zabbix服务器去Telnet客户机的10050端口,然后在客户机中查看10050被什么ip访问了,拿到这个ip之后,加到之 ...
- Centos 7 下 Corosync + Pacemaker + psc + HA-proxy 实现业务高可用
一.介绍: 1.本博客Corosync + Pacemaker + psc + HA-proxy 实现业务高可用,以httpd 服务实现高可用为例. 2.架构思路 a.三台web 节点,功能:全部安装 ...
- Win7系统不能记忆窗口大小与位置解决方法
似在某此系统优化后,无意发现系统在注销或重启后,打开资源管理器,它以默认大小及位置显示. 对于习惯自定义操作来说,甚为不便,遍找方法未有奏效者,但总萦绕心头,时时记起. 今日再找问题解决方法,难兄难弟 ...
- django的request介绍和APIView流程分析和CBV的流程分析
首先get请求的数据都在request.GET中,request.body中没有,因为只有post请求有请求体,request.body中的数据是请求体的数据 首先,我们还是用cbv的方式来讲解 我们 ...
- C#判断文件和文件夹是否存在 不存在则创建
using System.IO;string path = @"D:\accountDaoRu\"; if (Directory.Exists(path) == fa ...
- 【Android优化篇】提升Activity加载速度的方法
文章转自:http://www.jianshu.com/p/2007ca0290d3 作者: CoderFan 前言 这个也是我面试遇到的问题,当时只回答了一种情况,异步加载数据,没想到别的方式,回来 ...
- MySql5.5 SQL优化 慢查询日志存储
一.MySql的慢查询日志的开启和存储 1.查看是否把没有使用索引的SQL记录到慢查询日志中,查看 log_queries_not_using_indexes 变量; show VARIABLES L ...