交表(Send a Table)
#include<stdio.h>
#include<string.h>
#define N 50010
int phi[N],n,sum[N];
void phi_table()
{
int i,j;
memset(phi,,sizeof(phi));
phi[]=;
for(i=;i<=N;i++)
if(!phi[i])
for(j=i;j<=N;j+=i) /*筛法求欧拉函数值*/
{
if(!phi[j])
phi[j]=j;
phi[j]=phi[j]/i*(i-);
/*phi[j]保存不超过j且与j互质的正整数的个数*/
}
sum[]=;
for(i=;i<=;i++)
sum[i]=sum[i-]+phi[i];
} int main()
{
phi_table();
int i;
while(~scanf("%d",&n)&&n)
{
printf("%d\n",*sum[n]-);
}
return ;
}
/*转化为有多少对时,2与1互质,但是(2,1)和(1,2)算2对,
所以应该乘以2,但是(1,1)被算了两次,所以减去一次*/
交表(Send a Table)的更多相关文章
- UVA10820 交表 Send a Table
\(\Large\textbf{Description:} \large{输入n,求有多少个二元组(x,y)满足:1\leqslant x,y\leqslant n,且x和y互素.}\) \(\Lar ...
- Berkeley DB的数据存储结构——哈希表(Hash Table)、B树(BTree)、队列(Queue)、记录号(Recno)
Berkeley DB的数据存储结构 BDB支持四种数据存储结构及相应算法,官方称为访问方法(Access Method),分别是哈希表(Hash Table).B树(BTree).队列(Queue) ...
- UVa10820 Send a Table[欧拉函数]
Send a TableInput: Standard Input Output: Standard Output When participating in programming contests ...
- 聚簇(Cluster)和聚簇表(Cluster Table)
聚簇(Cluster)和聚簇表(Cluster Table) 时间:2010-03-13 23:12来源:OralanDBA.CN 作者:AlanSawyer 点击:157次 1.创建聚簇 icmad ...
- UVA 10820 - Send a Table 数论 (欧拉函数)
Send a Table Input: Standard Input Output: Standard Output When participating in programming contest ...
- UVA 10820 Send a Table euler_phi功能
除1,1其他外国x,y不等于 为 x<y 案件 一切y有phi(y)组合 F[x]= phi(i) 2<=i<=x 结果为 2*F[x]+1 Problem A Send a Tab ...
- MySQL 建表语句 create table 中的列定义
MySQL 建表语句 create table 中的列定义: column_definition: data_type [NOT NULL | NULL] [DEFAULT default_value ...
- 哈希表(Hash Table)原理及其实现
原理 介绍 哈希表(Hash table,也叫散列表), 是根据关键码值(Key value)而直接进行访问的数据结构.也就是说,它通过把关键码值映射到表中一个位置来访问记录,以加快查找的速度.这个映 ...
- 表优化 altering table OPTIMIZE TABLE `sta_addr_copy`
表优化 altering table OPTIMIZE TABLE `sta_addr_copy` [总结] 1.实际测试的结果是,在state sqlaltering table OPTIMIZE ...
- Hash表(hash table ,又名散列表)
直接进去主题好了. 什么是哈希表? 哈希表(Hash table,也叫散列表),是根据key而直接进行访问的数据结构.也就是说,它通过把key映射到表中一个位置来访问记录,以加快查找的速度.这个映射函 ...
随机推荐
- ZOJ 3230 Solving the Problems(数学 优先队列啊)
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3230 Programming is fun, Aaron is ...
- Computer form factor
http://en.wikipedia.org/wiki/Motherboard_form_factor Computer form factor From Wikipedia, the free e ...
- oracle spm使用1
oracle11g new feature SPM 有助于保持sql的语句特性,仅仅同意运行性能提高的运行计划. 它不同于stored outlines, spm在于稳定sql性能,而store ou ...
- XJTUOJ wmq的A×B Problem FFT/NTT
wmq的A×B Problem 发布时间: 2017年4月9日 17:06 最后更新: 2017年4月9日 17:07 时间限制: 3000ms 内存限制: 512M 描述 这是一个非常简 ...
- windows下安装RubbitMq
1.下载 下载 rabbitMQ :http://www.rabbitmq.com/download.html,安装rabbitmq需要erlang,下载erlang:http://www.erlan ...
- delphi 中OutputDebugString 函数的妙用(使用DebugView或者Pascal Analyzer软件,在运行过程中就能监视和捕捉日志,而且通过网络就能监视)
原文地址 https://www.peganza.com/delphi-and-outputdebugstring.html 曾经想要实时监控您的Delphi应用程序,并能够查看日志消息吗?当然,您始 ...
- SharePoint 2010 Pop-Up Dialogs SharePoint 2010 弹出对话框
SharePoint 2010 Pop-Up Dialogs SharePoint 2010 弹出对话框 SharePoint 2010 使得往你的站点加入对话框内容变得出乎意料的简单 ...
- MyEclipse 8.5 启动过程优化
前言:MyEclipse5.5 大小 139M:MyEclipse6.5 大小 451M:MyEclipse7.0 大小 649M:MyEclipse8.0 大小 772.3MB(速度方面比7.1和7 ...
- struts2 过滤器
Chain.doFilter的作用就是继续请求的传递,可传递给下一个filter也可传递给目标页面 如左侧传递给filter2,但fiter2使用上面或者下面的方法将倾情重定向到一个新的页面,而不再传 ...
- 使用JQuery.Validate插件来校验页面表单有效性
使用JQuery.Validate插件来校验页面表单有效性1. [代码] 常见的注册表单元素 <form action="#" method="post" ...