GCD Again HDU 1787(欧拉函数水题)

ACM:数论专题(5)——欧拉函数 题目描述:     定义函数φ(k)表示数字1...(k-1)中,和k互质的数字的个数。要求给定区间[L, R],找出在[L,R]范围内,φ(k)值最小的数字,如果有多个数字存在最小值,那么输出数值最小的一个。 解答: ·定理:        题目中定义的函数φ(k)称为“欧拉函数”,该函数具有如下的几个性质:     定理1:若:k为素数,那么:φ(k) = k-1 阅读详情

GCD Again

 Do you have spent some time to think and try to solve those unsolved problem after one ACM contest?
No? Oh, you must do this when you want to become a "Big Cattle".
Now you will find that this problem is so familiar:
The greatest common divisor GCD (a, b) of two positive integers a and b, sometimes written (a, b), is the largest divisor common to a and b. For example, (1, 2) =1, (12, 18) =6. (a, b) can be easily found by the Euclidean algorithm. Now I am considering a little more difficult problem:
Given an integer N, please count the number of the integers M (0<M<N) which satisfies (N,M)>1.
This is a simple version of problem “GCD” which you have done in a contest recently,so I name this problem “GCD Again”.If you cannot solve it still,please take a good think about your method of study.
Good Luck!

Input
Input contains multiple test cases. Each test case contains an integers N (1<N<100000000)(1<N<100000000). A test case containing 0 terminates the input and this test case is not to be processed.
Output
For each integers N you should output the number of integers M in one line, and with one line of output for each line in input.
Sample Input

2
4
0

Sample Output

0
1

直接用欧拉函数直接求

code:

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int Euler(int n){
    int ans = n;
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0){
            ans = ans / i * (i - 1);
            while(n % i == 0) n /= i;
        }
    }
    if(n > 1) ans = ans / n * (n - 1);
    return ans;
}
int main(){
    int n;
    while(scanf("%d",&n) != EOF){
        if(!n) break;
        printf("%d\n",n-Euler(n)-1);//减去n本身
    }
    return 0;
}
电磁流量计模拟前端电路设计与优化 模拟前端电路(AFE)是传感器信号处理的核心环节,通过放大、滤波和模数转换实现信号调理。其设计需重点考虑放大器共模抑制比(CMRR)和ADC分辨率等关键参数,在电磁流量计等工业测量应用中,AD8220仪表放大器与AD7172-2 Σ-Δ型ADC的组合能有效简化传统多级架构。现代过采样技术结合数字滤波可替代模拟滤波器,显著提升系统集成度与测量精度,这种设计方法同样适用于压力传感、生物电信号采集等需要高精度信号调理的场景。 阅读详情

相关推荐

使用vite+react+ts+Ant Design开发后台管理项目(四)

本文将引导开发者从零基础开始,运用、react、react-router、react-redux、Ant Design、less、tailwindcss、axios等前沿技术栈,构建一个高效、响应式的后台管理系统。通过详细的步骤和实践指导,文章旨在为开发者揭示如何利用这些技术工具,从项目构思到最终实现的全过程,提供清晰的开发思路和实用的技术应用技巧。使用vite+react+ts+Ant Design开发后台管理项目(一)使用vite+react+ts+Ant Design开发后台管理项目(二)

lbking666666的专栏 2006

HDU 1787(欧拉函数)

GCD Again<br />Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)<br />Total Submission(s): 517    Accepted Submission(s): 153<br /><br />Problem DescriptionDo you have spent some time to think and try to solve those unsolv

-- bird -- 1042

NVIDIA vGPU三种授权方式(个人玩家版)

NVIDIA vGPU三种方式搭建授权服务器(个人玩家版)

wstc2689784536的博客 8431

欧拉函数学习笔记及例题

前言数学可是信息学竞赛的精髓,导致了我们在做题的过程中经常碰到大大小小的关于数学的问题。欧拉函数便是其中之一,不知道欧拉函数很吃亏,不知道欧拉函数意味着你会找不出来一道找规律题的规律。欧拉函数定义:欧拉函数表示1-N中与N互质的数的个数;欧拉函数用希腊字母φ表示,φ(N)表示N的欧拉函数.举个栗子:φ(3): ∵在1到3中,有1,2,3三个数,1与除零以外的任何数互质,2与3的最大公因数为1,也可...

编程竞赛过程记录—学习笔记 4379

【Java】对接微信转账到零钱接口 Java微信商家转账 apiV3(该踩的雷都踩了)

配置apiv3依赖java代码。

Moonhwa的博客 4316

海康威视4G摄像头直连实战:不用萤石云,手把手教你用ISUP SDK搞定跨网段视频流

本文详细介绍了如何通过海康威视ISUP SDK实现4G摄像头的直连通信,提供了一套零平台费、自主可控的技术方案。文章涵盖技术选型、设备端配置、服务器端开发及高级应用场景,特别适合中小型安防项目,帮助开发者解决跨网段视频流传输难题,降低长期运营成本。

weixin_27076351的博客 467

欧拉函数

  在数论,对正整数n,欧拉函数是少于或等于n的数中与n互质的数的数目。此函数以其首名研究者欧拉命名,它又称为Eulers totient function、φ函数、欧拉商数等。  例如φ(8)=4,因为1,3,5,7均和8互质。  从欧拉函数引伸出来在环论方面的事实和拉格朗日定理构成了欧拉定理的证明。   φ函数的值   φ(1)=1(唯一和1互质的数就是1本身)。   若n是质数p的k次幂,

hqd_acm的专栏 1523

Ubuntu终端一键安装英伟达驱动:无需手动下载的完整指南

本文提供了一份在Ubuntu系统上通过终端命令一键安装英伟达显卡驱动的完整指南。该方法利用官方PPA源,无需手动下载驱动文件,可自动检测硬件并安装最佳版本,极大简化了流程,适合深度学习环境搭建等场景,有效提升安装效率与稳定性。

weixin_29232121的博客 180

GCD Again HDU - 1787 (欧拉函数 or 容斥原理)

Do you have spent some time to think and try to solve those unsolved problem after one ACM contest?  No? Oh, you must do this when you want to become a "Big Cattle".  Now you will find that this probl...

Coding 321

嵌入式开发之瑞芯微RK356x--基本环境搭建

嵌入式环境搭建

NexyHO的博客 617

Algorithm:【算法进阶之路】之算法面试刷题集合—数据结构的简介、最强学习路线(逻辑结构【数组-链表-栈和队列/树-图-哈希】、物理结构【元素/关系】、数据运算【十大排序/四大查找-图三大搜索-

​ Algorithm:【算法进阶之路】之算法面试刷题集合—数据结构的简介、最强学习路线(逻辑结构【数组-链表-栈和队列/树-图-哈希】、物理结构【元素/关系】、数据运算【十大排序/四大查找-图三大搜索-树三大遍历】、高级算法【枚举/回溯/递归/分治/动规/贪心】)、问题为导向的十大类刷题算法总结之详细攻略 目录 相关文章 数据结构思维导图 基本术语 一、数据结构的概述 二、数据的逻辑结构 三、数据的物理结构 四、数据的运算

头部AI社区如有邀博主AI主题演讲请私信—心比天高,仗剑走天涯,保持热爱,奔赴向梦想!低调,专注,谦虚,自律,反思,成长,还算比较正能量的博主,公益免费传播…内心特别想在AI界做出一些可以推进历史进程影响力的技术(兴趣使然,有点小情怀,也有点使命感呀 6849

HDU 1787 GCD Again(欧拉函数,水题)

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1997    Accepted Submission(s): 772 Problem Description Do you have spent some time...

weixin_34032779的博客 110

YOLOv11模型改进-模块-引入空间池化模块StripPooling 解决遮挡、小目标

本文介绍了一种新的空间池化策略,称为,用于场景解析。结构:包括两个平行路径,分别进行水平和垂直方向的条带池化,然后通过1D卷积层进行特征调整。:结合了条带池化和传统的空间池化,分别用于捕捉长距离和短距离的依赖关系。作用捕捉长距离依赖:通过长条形的池化窗口,有效捕捉分布离散的区域之间的关系。避免不相关信息干扰:窄条形的池化窗口有助于捕捉局部上下文,防止不相关区域干扰标签预测。提高场景解析性能:在多个基准数据集上,证明了这种方法能够显著提升场景解析的效果。

qq_64693987的博客 4204

HDU1787 GCD Again【欧拉函数】

GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 5927 Accepted Submission(s): 2749 Problem Description Do you have spent some time to think and try to solve those unsolved problem after o

海岛Blog 486

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

hdu 1787 GCD Again

hdu 1787 GCD Again http://acm.hdu.edu.cn/showproblem.php?pid=1787 ProblemDescription DoyouhavespentsometimetothinkandtrytosolvethoseunsolvedproblemafteroneACMcontest?N...

diansitao5461的博客 97

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

欧拉函数(HDU 1787 GCD Again,HDU 3501 Calculation 2,HDU 2824 The Euler function,HDU 2588 GCD)

文章目录一.定义/证明/板子二.典例:2.1.HDU 1787 GCD Again2.2.HDU 3501 Calculation 2 一.定义/证明/板子 定义ϕ(n)\phi (n)ϕ(n)为小于nnn且与nnn互质的数的个数,包含111,且ϕ(n)\phi(n)ϕ(n)是积性函数。 现在来求一下ϕ(n)\phi (n)ϕ(n) 如果n为质数,ϕ(n)=n−1如果n为质数,\phi(n)=n-1如果n为质数,ϕ(n)=n−1 如果n=ap,a为质数,那么ϕ(n)=ap−ap−1=ap−1∗(a−1)=

weixin_43908980的博客 462

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

HDU - 1787 - GCD Again 【 欧拉函数】题解

目录1.题目2.代码 1.题目 Do you have spent some time to think and try to solve those unsolved problem after one ACM contest? No? Oh, you must do this when you want to become a “Big Cattle”. Now you will find that this problem is so familiar: The greatest common div

林深不见鹿 的博客 361

HDU -1787 GCD Again(欧拉函数)

GCD Again Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description Do you have spent some time to think and try to solve those unsolved problem after...

名字太长容易被发现并打死 467

HDU 1787 GCD Again

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4384    Accepted Submission(s): 1999   Problem Description Do you have spent some ...

~ 456

hdu1787 GCD Again poj 2478 Farey Sequence 欧拉函数

hdu1787,直接求欧拉函数 #include <iostream> #include <cstdio> using namespace std; int n; int phi(int n){ int ans=n; for(int i=2; i*i<=n; i++) if(n%i==0){ ans -...

dianjiaxian1205的博客 171

hdu1787-GCD Again

http://acm.hdu.edu.cn/showproblem.php?pid=1787 #include #include #include #include using namespace std ; #define INT __int64 int enlerfun( int n ) { int tempnum = 1 ; int i ; for( i = 2 ; i *

luckycoding的专栏 1119

HDU1787 GCD Again

HDU1787 GCD Again欧拉公式 Problem Description Do you have spent some time to think and try to solve those unsolved problem after one ACM contest? No? Oh, you must do this when you want to become a

Brust Link 692

HDU1787——GCD Again

Problem Description Do you have spent some time to think and try to solve those unsolved problem after one ACM contest?No? Oh, you must do this when you want to become a "Big Cattle".Now you will fi

Alex 615

hdu 1787 GCD Again 欧拉函数小水水 数论

GCD Again Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1542    Accepted Submission(s): 578 Problem Description Do you have spent som

hnust_xiehonghao的专栏 2428

HDU - 1787 GCD Again

Do you have spent some time to think and try to solve those unsolved problem after one ACM contest? No? Oh, you must do this when you want to become a “Big Cattle”. Now you will find that this problem...

weixin_43244265的博客 193

HDU - GCD(欧拉函数)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2588Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description The greatest common divisor GCD(a,b) of two po...

ityanger的技术栈 2684
上一篇: HDU 2841 Visible Trees(容斥原理+解释)
下一篇: hdu 1695 GCD(莫比乌斯反演经典入门||容斥原理+欧拉函数)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值