POJ2478 Farey Sequence

RK3568 Linux驱动开发实战:从SDK环境搭建到模块编译 本文详细介绍了基于RK3568芯片的Linux驱动开发实战流程,从搭建SDK编译环境到模块化编译驱动。重点讲解了Ubuntu系统准备、依赖包安装、SDK源码获取与目录结构解析,以及如何高效进行内核和外部驱动模块的编译与调试,为嵌入式Linux驱动开发者提供了清晰的入门指南和实用避坑技巧。 阅读详情
Farey Sequence
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 15250 Accepted: 6058

Description

The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few are 
F2 = {1/2} 
F3 = {1/3, 1/2, 2/3} 
F4 = {1/4, 1/3, 1/2, 2/3, 3/4} 
F5 = {1/5, 1/4, 1/3, 2/5, 1/2, 3/5, 2/3, 3/4, 4/5} 

You task is to calculate the number of terms in the Farey sequence Fn.

Input

There are several test cases. Each test case has only one line, which contains a positive integer n (2 <= n <= 10 6). There are no blank lines between cases. A line with a single 0 terminates the input.

Output

For each test case, you should output one line, which contains N(n) ---- the number of terms in the Farey sequence Fn. 

Sample Input

2
3
4
5
0

Sample Output

1
3
5
9

Source

POJ Contest,Author:Mathematica@ZSU


其实题意就是让你找出n及小于n的数的互质数共有多少对,直接求欧拉函数之和。

在这里1的欧拉函数是1,但从题面看来是不需要统计这个1/1的。

AC代码:

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const double PI = acos(-1.0);
const double eps = 1e-6;
const int INF = 1000000000;
const int maxn = 1000010;
int T,n,m;
int table[maxn];
void phi_table()
{
	for(int i=2;i<=1000001;i++) table[i]=0;
	table[1]=1;
	for(int i=2;i<=1000001;i++) if(!table[i]){
		for(int j=i;j<=1000001;j+=i){
			if(!table[j]) table[j]=j;
			table[j]=table[j]/i*(i-1);
		}
	}
}
int main() {
	phi_table();
    while(~scanf("%d",&n)&&n!=0) {
    	long long sum=0;
		for(int i=2;i<=n;i++){
			sum+=table[i];
		}
		printf("%lld\n",sum);
    }
    return 0;
}








Win11下HP LaserJet M1136驱动卡“新设备已连接”的根治方法 即插即用(PnP)机制让USB设备插入即被系统识别,但也可能成为老式打印机驱动安装的“拦路虎”。以HP LaserJet M1136 MFP为例,它作为USB复合设备,一条线同时枚举打印与扫描接口,而Windows 11默认自动从更新库安装驱动,导致官方安装包与系统PnP流程互相等待,界面卡在“新设备已连接”。理解这一冲突原理,是解决同类驱动安装失败的关键。在实际工程中,通过关闭系统自动驱动下载、清理驱动库残留、控制USB插线时机,甚至手动指定INF驱动文件,都能稳定完成安装。本文提供了一套已验证的完整流程 阅读详情

相关推荐

freeswitch之呼叫中心acd模块开发

一、定义: ACD(Automatic Call Distributor) 自动呼叫分配,也叫智能选择座席。它是呼叫中心整个前台接入系统逻辑功能的描述:把接入的呼叫转接到正确的座席员桌前。ACD是现代呼叫中心有别于一般的热线电话系统和自动应答系统的重要标志,其性能的优劣直接影响到呼叫中心的效率和顾客的满意度。 二、ACD包含的功能点: 1 、程控交换功能 ACD在本质上也是交换机的一种类型,必须具有程控交换最基本的话务交换功能。 2 、排队功能 ACD必须具有话务排队的功能,所谓排队是指在内线都

飞鸟的博客 1873

POJ2478 Farey Sequence【欧拉函数】

Farey Sequence Time Limit:1000MS Memory Limit:65536K Total Submissions:18635 Accepted:7495 Description The Farey Sequence Fn for any integer n with n &gt;= 2 is the set of ir...

海岛Blog 749

【Clickhouse从入门到精通】第51篇:ClickHouse权限管理体系详解

摘要 本文是ClickHouse权限管理系列文章的第51篇,重点解析ClickHouse RBAC权限体系中的GRANT/REVOKE机制。文章详细介绍了GRANT语句的基础语法与权限类型,包括SELECT、INSERT等常规权限以及WITH GRANT OPTION转授权功能。特别深入讲解了列级权限的实现方式,通过SELECT(col1,col2)语法实现字段粒度的访问控制,并展示了权限查询与验证方法。本文还对比了ClickHouse 20.4版本前后权限管理体系的差异,为构建安全的多租户数据平台提供了关

xyghehehehe的专栏 445

【POJ2478】Farey Sequence

【题目大意】 求在[1,n]范围内的(a,b)且a≠b,满足gcd(a,b)=1的个数 【题解】 欧拉函数裸题,无需多言。 1 /************* 2 POJ 2478 3 by chty 4 2016.11.3 5 *************/ 6 #include<iostream> 7 #include&...

anzhi7214的博客 149

WRF中使用ERA5再分析数据

   本人在做一些实例时,需要用到最新的ERA5再分析数据集,其中我下载的是ERA5 hourly data on pressure levels form 1979 to present和ERA5 hourly data on single levels from 1979 to present中的3天数据。 1、注册climate copernicus账号 下载ERA5数据前先要注册其账号 2、选择变量    WRF中对于气象数据的字段有具体的要求, ......

GIS 8179

超详细的wireshark抓包使用教程

说明:数据包列表区中不同的协议使用了不同的颜色区分。协议颜色标识定位在菜单栏View --> Coloring Rules。如下所示WireShark 主要分为这几个界面1. Display Filter(显示过滤器), 用于设置过滤条件进行数据包列表过滤。菜单路径:Analyze --> Display Filters。2. Packet List Pane(数据包列表), 显示捕获到的数据包,每个数据包包含编号,时间戳,源地址,目标地址,协议,长度,以及数据包信息。

Forget_liu的博客 1万+

POJ2478 Farey Sequence【快速求欧拉函数】

POJ2478_Farey Sequence【快速求欧拉函数】 题目大意: 给你一个数n,对于0 < a < b <= n,求真分数a/b的个数 思路:因为a/b为真分数,所以a和b互质。 求真分数a/b的个数。其实就是求0 < i <= n中,小于i的正整数中, 有多少个与i互质的数。累加起来就是真分数a/b的个数。 其实就是欧拉函数 因为n的规模为10^6,可用快速求欧拉函数的方法求得(类似于筛法求素数)。 根据推论:设P是素数, 若p是x的约数,则E(x*p)=E(x)*p. 若p不是x的约数

程序员充电站(itcharge) 1623

聚类技术:发展历史、主要分类与重要论文解析

在数据挖掘和机器学习的广袤领域中,聚类作为一种强大的无监督学习技术,一直扮演着至关重要的角色。它能够帮助我们从海量的数据中发现隐藏的模式和结构,将相似的数据对象归为一类,从而为进一步的分析和决策提供有价值的信息。

qq_48131648的博客 2635

POJ 2478 Farey Sequence

POJ 2478 Farey Sequence 题目链接 Description The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few are F2 = {1/2} F3 = {1/

旺崽的博客 2556

别再傻傻分不清!5分钟搞懂倾斜摄影里‘地面分辨率’和‘模型精度’到底啥关系

本文深入解析倾斜摄影中‘地面分辨率’与‘模型精度’的关系,帮助读者快速理解两者的本质区别与内在关联。通过实战案例和公式计算,详细说明如何从航飞设计到精度验证全流程控制,避免常见认知误区,并针对不同应用场景提供精度需求建议。

weixin_33700350的博客 483

coredump文件的原理是啥

Core Dump(核心转储)是操作系统在程序崩溃(如段错误、非法指令等)时自动生成的一个文件,它包含了程序崩溃瞬间的。通过 core dump,开发者可以像“时间回溯”一样检查程序崩溃瞬间的状态,是调试复杂问题的利器!终止时,Linux 内核会生成 core 文件。不会生成 core dump,因为它们是“优雅终止”信号。这样 core 文件会直接压缩存储,节省磁盘空间。的文件(类似可执行文件),可以用。Core 文件本质上是一个。

二进制君 395

POJ 2478 Farey Sequence

名字是法雷数列其实是欧拉phi函数              Farey Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11246   Accepted: 4363 Description The Farey Sequence Fn for any

码代码的猿猿 703

【应用】打造你的安全本地AI购物助手:OpenClaw + 淘宝MCP部署全攻略

本文介绍了在Ubuntu虚拟机中配置OpenClaw连接Windows宿主机的淘宝MCP服务的两种方案。核心原理是通过修改MCP服务监听地址或SSH隧道转发,实现跨网络访问。方案1推荐修改MCP服务绑定0.0.0.0并配置防火墙放行端口,适合长期使用;方案2通过SSH隧道转发,适合临时测试。文章详细说明了环境准备、配置文件修改及两种互通方案的具体实施步骤,重点解决了虚拟机与宿主机网络互通的关键问题。

海兰 1336

[poj2478] Farey Sequence

题目描述  Farey序列Fn,要求计算a/b(0 < a < b <= n并且gcd(a,b)=1)的个数,例如:   F2={1/2}   F3={1/3,1/2,2/3}   F4={1/4,1/3,1/2,2/3,3/4}   F5={1/5,1/4,1/3,2/5,1/2,3/5,2/3,3/4,4/5}   你的任务是计算Farey序列Fn的个数输入格式包含多组测试数据

Bill_Yang_2016的博客 532

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

poj2478 Farey Sequence

筛法求欧拉函数模板题

YHaX的博客 357

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

【poj 2478】 Farey Sequence

Description The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few are

TLECODE的博客 492

蓝牙模块HM-10手册

蓝牙模块HM-10手册,该手册对蓝牙模块HM-10进行了详细的介绍和使用方法以及一些AT指令。

POJ - 2478 Farey Sequence

Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18768   Accepted: 7554 Description The Farey Sequence Fn for any integer n with n &gt;= 2 is the set of irreducible ration...

LOVE&AI的博客 348

poj 2478 Farey Sequence

Farey Sequence Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14278   Accepted: 5641 Description The Farey Sequence Fn for any integer n with n >= 2 is the se

菜鸟起飞的平台 318

Poj 2478 Farey Sequence

Farey Sequence Time Limit:1000MS Memory Limit:65536K Total Submissions:12815 Accepted:5003 Description The Farey Sequence Fn for any integer n with n &...

137

poj 2478 Farey Sequence

B - Farey Sequence Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Description The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible

u012312566的博客 315

POJ 2478 Farey Sequence

题目链接:点我The Farey Sequence Fn for any integer n with n >= 2 is the set of irreducible rational numbers a/b with 0 < a < b <= n and gcd(a,b) = 1 arranged in increasing order. The first few are F2 = {1/2}

wood 310
上一篇: 湖南省第十二届大学生程序设计竞赛A题 2016 (csuoj1803)
下一篇: POJ1061青蛙的约会(扩展欧几里得)
liblnuex
博客等级 码龄12年 2粉丝 16原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值